Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: math: add Tau in constants #40663

Closed
roipoussiere opened this issue Aug 10, 2020 · 14 comments
Closed

proposal: math: add Tau in constants #40663

roipoussiere opened this issue Aug 10, 2020 · 14 comments

Comments

@roipoussiere
Copy link

Add Tau in mathematical constants.

In many cases, formulas can be more elegant using the Tau constant instead
of Pi. You will find a good number of arguments and explanations
in the Tau manifesto, which describes Tau as:

the most important numbers in mathematics, perhaps the most important:
the circle constant relating the circumference of a circle to its linear
dimension. For millennia, the circle has been considered the most
perfect of shapes, and the circle constant captures the geometry of the
circle in a single number.

The constant is based on the corresponding page in the online
encyclopedia of integer sequences
, and is also
equal to math.Pi * 2.

Usage:

perimeter := math.Tau * radius

I just created the PR #40662 that adds the constant, but I'm now creating this issue to have some feedback before signing the CLA.

@andybons andybons changed the title math: add Tau in constants proposal: math: add Tau in constants Aug 10, 2020
@gopherbot gopherbot added this to the Proposal milestone Aug 10, 2020
@deanveloper
Copy link

While I am a big fan of tau, I don't see the problem in putting const Tau = math.Pi * 2 at the beginning of a program

@zephyrtronium
Copy link
Contributor

In my experience, people who dislike Tau never understood trigonometry, nor mathematics in general.
Looking at you, @seankhliao and @zephyrtronium

I am a mathematician. I've used pi a lot, and tau almost none. Trigonometry isn't the only place where pi arises. Convention and inertia matter as well; schools teach pi largely for historical reasons, but as long as they do, writing 2π, or 2*math.Pi, is clear to a much wider audience than τ. I also don't appreciate personal attacks.

Just like I would hate having to do

const E = 2.71828182845904523536028747135266249775724709369995957496696763

everywhere I used it.

This is a false analogy. const Tau = 2 * math.Pi is significantly shorter and requires neither copying nor memorization. You can also put either in a separate package so that you don't have to redefine it in each new project that needs it, if the "code duplication" really does matter so much.

@deanveloper
Copy link

I understand that adding such a const would break your code, and since you don't see the problem with adding the directive each time, your position makes sense ; thanks again for taking the time to reply.

Adding a const to the math package actually won’t break any code. However, the more things that get added, it starts to become hard to search packages, learn the language, etc. It may seem like a relatively small thing to add, but at the same time, I would personally hate for Go to have a constant for every greek letter, haha.

@ianlancetaylor ianlancetaylor added this to Incoming in Proposals (old) Aug 10, 2020
@ianlancetaylor
Copy link
Contributor

Are there are any other languages that provide Tau in their standard library?

For example, in C, in <math.h> on GNU/Linux, I see M_PI, but I don't see M_TAU.

@Goutte
Copy link

Goutte commented Aug 10, 2020

Are there are any other languages that provide Tau in their standard library?

From https://tauday.com/state-of-the-tau :

The last year saw the addition of tau to many computer languages and frameworks (adding to a list that includes Python, Julia, and many others):

@roipoussiere
Copy link
Author

I don't understand all theses thumbs down. I respect your choice of preferring Pi over Tau, but why be against adding Tau? You will probably don't even notice the difference if it's added, and as @deanveloper pointed out, it won't break any code (and of course wont affect performance).

There are thousands of issues here, I bet that for 9/10 of them, I just don't care. I'm not going to add a thumb down for all of them. :D

So this is not a "Pi vs Tau battle". It's just a suggestion to add a constant that will make some developers happier. You prefer Pi? Lucky you! You have actually nothing to do, there is already math.Pi (and I'm not asking to remove it). :)

While I am a big fan of tau, I don't see the problem in putting const Tau = math.Pi * 2 at the beginning of a program

Yes, indead. I can also write at the beginning of a program:

const Pi  = 3.14159265358979323846264338327950288419716939937510582097494459

Luckily there is math.Pi that makes things more practical. In the same way, I'm asking math.Tau just to make things more practical for some users.

Are there are any other languages that provide Tau in their standard library?

You suggests level down: we don't necessary have to look for other institutions before to addopt an improvement. As @zephyrtronium said, there is a huge inertia with Pi, so it's understandable that Tau is not as present as Pi.

A programing language is basically a convention to convert intelligible instructions into machine code: here, for me and other developers, Tau is more intelligible than Pi. Just consider it. Please. :)

@yiyus
Copy link

yiyus commented Aug 10, 2020

I don't understand all theses thumbs down.

There are people who don't know tau, but know pi. Even if you would find a bit more convenient using math.Tau instead of 2*math.Pi, I'd prefer that all Go code used pi so that every developer can instantly get it.

As someone who daily works with angles and orientations, I also have quite strong opinions on why tau is not such a good idea, but I do not think the Go issue tracker is the place to have that discussion.

@ianlancetaylor
Copy link
Contributor

Are there are any other languages that provide Tau in their standard library?

You suggests level down: we don't necessary have to look for other institutions before to addopt an improvement. As @zephyrtronium said, there is a huge inertia with Pi, so it's understandable that Tau is not as present as Pi.

In areas where Go has not explicitly decided to develop new ideas, we prefer to follow the lead of other projects. I don't think this is leveling down; it's just being deliberate in making changes.

@dmitshur
Copy link
Contributor

dmitshur commented Aug 10, 2020

Are there are any other languages that provide Tau in their standard library?

Edit: I wrote something but missed a comment above which provides a more complete answer to this question.


See also relevant past discussion in proposal #24759.

@JosephTLyons
Copy link

JosephTLyons commented Aug 11, 2020

Are there are any other languages that provide Tau in their standard library?

For example, in C, in <math.h> on GNU/Linux, I see M_PI, but I don't see M_TAU.

Rust.

https://doc.rust-lang.org/nightly/std/f64/consts/constant.TAU.html

It was stabilized a few weeks back and will be released in Rust 1.47 I believe.

As a side note, it seems really strange to me that there would be any resistance to adding this in as a numerical constant, with any language.

@rsc
Copy link
Contributor

rsc commented Aug 11, 2020

C provides not just Pi but Pi/2 (M_PI_2) and Pi/4 (M_PI_4).
Go does not provide the last two because Pi has been provided in enough precision that you can write Pi/2 and Pi/4 directly instead of learning new names.

If you need to write a program in terms of Tau, then add const Tau = Pi*2 to your program.
This need not be in the standard library.

@Goutte
Copy link

Goutte commented Aug 12, 2020

There's a Go package for Tau, whose usage may help provide some metrics in the future : https://github.com/FranklinChen/gotau

Closing note, just to clarify, though: it's not about needing to write a program in terms of Tau ; it's about needing to write a program using in any form the topology of a circle. (usually through trigonometry, but the circle is everywhere).
When you think in terms of Tau, mathematics become simpler to understand by kids. The Khan Academy understands this quite well.

@rsc
Copy link
Contributor

rsc commented Aug 12, 2020

Great, I am glad that the package has already been created outside the standard library.

We can revisit in (say) five years if mathematics has overwhelmingly shifted away from Pi to Tau, but in the meantime, this seems like a likely decline.

@rsc rsc moved this from Incoming to Likely Decline in Proposals (old) Aug 12, 2020
@rsc
Copy link
Contributor

rsc commented Aug 26, 2020

No change in consensus, so declined.

@rsc rsc closed this as completed Aug 26, 2020
@rsc rsc moved this from Likely Decline to Accepted in Proposals (old) Aug 26, 2020
@rsc rsc moved this from Accepted to Declined in Proposals (old) Aug 26, 2020
@golang golang locked and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

10 participants