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`.

4 Likes

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

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).

1 Like

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

https://crates.io/crates/natural_constants

1 Like

... 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.

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

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.

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.

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.

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

5 Likes

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”.

2 Likes

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`. Can anyone think of a better name for the `PI`-named variant?

Edit: Another option is `TWO_PI`.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.