Add Tau to std::f64::consts?


#1

I was wondering if adding Tau (2.0 * PI) to std::f64::consts has been considered. It’s a very common constant and there are already several other constants which are fractions of PI, for example std::f64::consts::FRAC_PI_8.

As a small data point, Python recently added math.tau.


#2

It was proposed once, in the long ago: https://github.com/rust-lang/rust/pull/15248

See also: https://github.com/rust-lang/rfcs/issues/1486


#3

In principle, a math constant with the value 2∙π would be a Good Thing, as it would have one or two more bits of precision. [This is wrong, see below.]

In practice, I’m worried about confusion with the existing consts::FRAC_2_PI and with C’s M_2_PI, which are both 2/π instead. (And FRAC_PI_2 and M_PI_2 are π/2.)

I object on principle to the name tau; the tau campaign is quixotic and should not be encouraged, and τ has several other established uses in mathematics (most prominently the scale factor in a Lorentz transform).


#4

Alternatively I’m happy to add all kinds of constants here:

https://crates.io/crates/natural_constants


#5

In principle, a math constant with the value 2∙π would be a Good Thing, as it would have one or two more bits of precision.

It would have exactly the same precision as result of the expression 2.0*std::f64::consts::PI. Nevertheless I still think it would be useful.


#6

… Aw, crud, you’re right. We’re just incrementing the exponent.

I’m afraid that means I think it isn’t a useful thing to add.


#7

It’s just as useful as FRAC_PI_2 decrementing the exponent, no?


#8

Ahaha, I saw this “tau” mentioned couple of times on the internet, but I had no idea there’s such a drama happening, with manifestos and everything.


#9

Internet holy wars aside, I doubt I’m the only one who’s never heard of tau before but would immediately know what 2_PI is.


#10

I don’t exactly even disagree with the assertion that 2π is in some sense “more fundamental” than π; it’s just that we have 3,800 years worth of mathematical writings that use π, making the tau proposal a strong contender for the biggest proposed backward compatibility break in written history, and the benefits are not nearly worth it. :wink:

Gotcha! The existing constant with that name is 2 over pi.


#11

I think such a constant would be useful given that there are already similar constants in place.

As for the symbol itself: ‘τ’ is a cute idea, but in practice I have never seen a mathematician or physicist use it in a non-humorous manner … assuming they are even aware of it! The whole “τ vs π debate” seems nothing more than a bikeshedding contest, on par with “spaces vs tabs”.


#12

Unfortunately 2_PI is not a valid identifier because it starts with a number. It would need to be something like PI_MULT_2 or PI_TIMES_2. :confused: Can anyone think of a better name for the PI-named variant?

Edit: Another option is TWO_PI.