C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal to add the circle constant "tau" to the list of C++ mathematical constants

From: Phil Endecott <std_proposals_list_at_[hidden]>
Date: Sat, 24 Aug 2024 14:37:45 +0100
Aaron Franke wrote:
> As of C++20, ISO C++ has a collection of useful mathematical constants in the numerics library: https://en.cppreference.com/w/cpp/numeric/constants
> However, there is an important constant missing: The circle constant "Tau", symbol "?", with a value of 2*? or about 6.283185307179586476925286766559...

Note that Boost.Math has 2*pi, as well as pi/2 and various other things
that aren't in the
standard:

   https://www.boost.org/doc/libs/1_86_0/libs/math/doc/html/math_toolkit/constants.html

This predates the C++ standardised constants and is referred to in the proposal:

   https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0631r8.pdf

I was hoping to find some discussion in the paper about the rationale
for not including
multiples or fractions of other constants. The paper does say, on page
6, that "we don't
have to provide replacements for both M_PI and M_PI_2 and M_PI_4. The
user will be
able to divide the M_PI replacement by 2 and by 4 ...". But there isn't
any rationale
for why the provided constants should be limited only to those that the
user cannot
easily form from other constants. Does anyone recall the discussion?

One issue with these fractions and multiples is how to choose names. I
am surprised
to learn that M_2_PI means "2 / pi" not "2 * pi"; I'm going to go and
grep all my code
now to see if I've ever used it. The boost constants are a bit more
verbose and perhaps
clearer, i.e. two_pi vs. two_div_pi. But which is better, 2*pi or
two_pi? And which is
better, two_thirds_pi or 2/3*pi?

Regarding "tau", personally I don't like it. If I were reading someone
else's code and
saw tau mentioned I wouldn't confidently know what it meant, whereas I
think some
large fraction of the population of the planet know what "2 pi" means.
It seems that
there is a group of people who feel that tau is in some sense better
than pi and we
should all change, but that reminds me of decimal time and esperanto. Aaron's
paper says that it "makes many expressions easier to read", but I
disagree with that.


Regards, Phil.

Received on 2024-08-24 13:37:49