-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add constants based on Archimedes' original circle constant #15248
Conversation
I'd thank you to leave a more constructive comment. I will respond just as flippantly by refering to the Tau Manifesto once again, which has a complete rebuttal of all of the Pi Manifesto's relevant points. |
It comes itself in response to that Tau thing, the point being that there's no sheer advantage to one or the other because there are formulas involving both in various domains. If anything, pi avoids having to divide by two in a number of formulas and most of all, it's what everyone uses. |
Please keep the discussion focused on why this is a good addition to Rust. It has a cost by increasing the size of the API -- without adding any utility, only (unproven) convenience. |
@adrientetar, the Tau Manifesto was updated last year with the aforementioned rebuttals. @blake2-ppc is correct that this is not the place for such rhetoric, as it's been talked to death elsewhere. That said, I would not submit this pull request if I did not think that it had value beyond a historical oddity. The significance of τ to any programming language is simply in the intuitiveness of calculations involving radian measure. There are a growing number of practitioners, educators and students who have embraced it as the more natural and intuitive choice for practically every application, already finding use even in engineering and science publications. Again, I have no need of making this case here, as it is has already been laid out in considerable detail at http://tauday.com. The patch contains almost no actual additional constants (aside from τ/3 ≡ 2π/3 and 1/τ ≡ 1/(2π) for completeness), and instead defines many of them in terms of their equivalencies, e.g. FRAC_2_TAU ≡ FRAC_1_PI. The documentation also makes clear the equivalence. There is no need for Rust to make any sort of stance on their relative usefulness to include them; in fact, it would be the most neutral stance to accommodate both. Programmers accustomed to π need not make any new life decisions, and project managers are also free to enforce the exclusive use of either constant in their style guide, although the equivalence is rudimentary. If the primary remaining concern is API bloat, it is my understanding that dividing by powers of two is not only trivial, but preserves floating-point precision on all target platforms, and that many of the constants defined in f32 and f64 could be removed without significant inconvenience. Assuming Rust already optimizes inline literal arithmetic (of which I am not certain), removing all circle constants but τ ≡ 2π, π ≡ τ/2, τ/3 ≡ 2π/3, π/3 ≡ τ/6, 1/τ ≡ 1/(2π), and 1/π ≡ 2/τ (that's 12 constants, 6 equivalence pairs) would not visibly add programmer inconvenience nor runtime inefficiency, and may instead make trigonometric calculations clearer and more intuitive for users of either constant family. The constant FRAC_2_SQRTPI := 2/√π could be retained if desired, although I have come to understand that it is merely a holdover from C99's "math.h", for use in the already available error functions erf() and erfc(). Most of the factors/multiples of 2 also appear to be holdovers. I already considered making the above changes, but decided I would defer to opinion first. |
I see no problem with adding tau. Adding extra API normally carries the cost of maintenance, but these aren't functions/types, they're constants that are, well, constant. They'll never change. |
Thanks for the input @kballard. Nevertheless, do you have any thoughts about trimming down the list of constants? I just confirmed with #rust that LLVM has very good constant folding, so it's likely that the only issue with removing some powers-of-two redundancy would be their use in existing code. Would that constitute excessive refactoring (whether within or without Rust itself)? |
I don't know. I'm not sure why we have so many constants for this. In C (in |
I'm not particularly opposed to adding tau, since as @kballard says there's not a lot of overhead to doing so, and there seems to be a growing consensus about its usefulness. If we do that we should recognize and understand the ideological implications (there's no 'need' for tau in std). I agree there are too many constants here. I know @nikomatsakis is a tau fan. |
Alright, since the verdict is "too many constants", I made some very aggressive cuts, removing every factor of 2, resulting in fewer constants than we started with. Factors of 3 remain in order to avoid a slight rounding error that occurs in double precision. Recreating any of the missing values such as I split the removals into two commits so that the last commit can be cherry-picked out of the merge if it's deemed too aggressive. I did however note that none of the multiples or divisions of π are even used anywhere in this codebase, only I also removed |
In several years of tertiary mathematics education (at universities on both sides of the world) I've never seen anyone use τ = 2π in reality. I would mildly prefer that we wait a while before adding such constants, as it would be weird for Rust to be left with these That said, I don't have strong objections. |
There is zero mathematical consensus that τ is more useful. If there were, or if the issue were even being debated, one would expect a search of a reputable journal to yield a single journal article about tau. But this is not the case. There is not a single mention of replacing pi or using tau. Moreover, the first page of articles in both the "tau" and "tau pi" search results all use π! And π is more fundamental anyways. The general, n-dimensional formula for the volume of an n-ball is If Rust were to add "TAU_*" constants, we'd become "that language with tau". These constants would be used by no one: not engineers, not scientists, not mathematicians, just people who follow the Tau Manifesto. I would be dismayed if Rust joined the τ-people, or even commented on such a marginal issue. It would be like if MIT started giving equal time to phlogiston theory in their freshmen chemistry classes, or equal time to intelligent design in their biology classes, out of respect for the controversy. When the Journal of Mathematical Physics publishes a secondary analysis acknowledging the usefulness/betterness of τ (or even a single damn article about it), let me know. Until then, keep it out of Rust. π is more fundamental, and is used by actual mathematicians and scientists. Let's not fan this flame. |
I am also pretty 👎 on Tau. |
In one year of Mathematics and Engineering, I haven't heard about that either. |
@alexchandel I do wish more people would choose to spend as much time reading this very comprehensive, easily digested and repeatedly linked manifesto as they do making arguments in ignorance of it. Since this is apparently the forum for such arguments now, though, I'd be happy to oblige: It's actually true that τ is not particularly fundamental to n-ball geometry, but neither is π. Section 5 of the article decomposes the Gamma function in the n-ball volume formula to find that the fundamental constant behind it is actually the measure of a right angle, τ/4 = π/2. This makes geometric sense, since every new dimension added to the n-space is orthogonal to the last. Nonetheless, it seems much sillier to suggest that we use that number in every formula than either π or τ. In fact, the entire above argument is a red herring; the fact remains that τ is the most fundamental number with respect to the circle (2-ball), which is precisely why it lends itself to more natural radian representations than π. The constant we are debating is called the circle constant, after all. Frankly, it's insulting to compare this idea, something that should just be mathematical common sense, to things like phlogiston theory, but not as degrading as hearing the same flawed arguments about π's specialness repeatedly. I do however accept the dilemma that Rust might not be ready to accept τ until wider acceptance is reached elsewhere (re: @huonw). I also realize that examples of this may be difficult to find, even if they do exist (and yes, even in reputable journals). That's precisely why I had hoped to appeal to logic and intuition, rather than sentiment and politics, although I perhaps overestimated the patience of other people to simply read the manifesto and let it do the talking for me. Either way, putting this merge on hold is understandable. I can wait. |
Anyone who wants Tau and Tau-based math can write a Cargo package for it. |
It's just a constant, there's not much logic behind the scenes. Likewise my intuition is what's been taught to me at school: pi. As the pi manifesto shows, there is also a handful of formulas that are better expressed with pi so that's just a matter of cherry-picking. |
@steveklabnik Unlikely; most would simply put the following in their global/module space:
This alone is adequate for most practical uses, uses exactly as many lines as including a package, and shouldn't conflict with other modules. Since it is already necessary to go through the helper functions in My only disappointment is in the poor rhetoric displayed here. I'm growing a little tired of it... |
@bugQ I've read that before, and the section in the Tau Manifesto you reference doesn't make your case. It begins by replacing Gamma, a uniquely constrained meromorphic function, with the discontinuous floor function, the almost-nowhere-defined double factorial, a |
@alexchandel You apparently ignored everything I wrote after the words "Section 5". I suppose it's too much to ask to read both; it's only either one or the other at a time. You'll note that I already explained that this particular line of argumentation is irrelevant to the purpose of introducing τ in the first place. Please let sleeping dogs lie. |
@bugQ There's no need to be combative; this is a courteous, listening community. You said that my point was refuted in the Tau Manifesto, and I showed this wasn't the case. Dismissing my point as irrelevant isn't correct either: You emphasize the 2-dimensional embedding, and argue τ is the fundamental circle constant, being the ratio of S_1 to r^1. I could just as easily argue that π is the fundamental circle constant, being the ratio of V_2 to r^2. But both of these numbers have meaning beyond the 2D case, and when you derive the general formulae, all of the integrals except the first are from |
@alexchandel Can you please drop this? @bugQ has already closed this issue and stated multiple times that he's ok with waiting for more widespread traction before trying to get |
fine by me. Edit to avoid email spam. @bugQ if you want to continue our conversation, want to repost at alexchandel/wall? |
Actually, I feel like I deserve @alexchandel an explanation, since the answer to their question is apparently subtle. As I said before (twice), you are correct that the generalizations of S and V do not reveal any aesthetic preference for either τ or π, but they do reveal a point against π: that its importance is incidental, rather than fundamental. The underlying reason is quite simple: as long as π is defined by a circle's diameter, it remains incongruous with the entirety of geometry. In fact, I can't think of a single formula outside of the definition π = C/d that forgoes r in favor of d. This simple fact is what underlies every single failing of π, from calculus to particle physics. I would encourage you to reread Section 5.2 (and perhaps the others as well) with that in mind. There is one last ray of hope, though: it follows that π would finally earn its stars if we were to define circles in a way that employed the diameter in a non-trivial way and endeavored to use d in place of r in all of geometry. Disregarding the havok it would wreak on the concept of "radians" and who knows what else, I submit that even if such a non-trivial use of d were found, it would not match the simplicity of the current definition. Either way, the far easier method of resolving this incongruency is to replace the circle constant, instead of r. |
We could remove |
oh goodness. this PR is embarrassing. please leave it be. Not that I wouldn't still like to see the constant introduced, but I'd hope whoever does would have better decorum than the me of 3 years ago. |
I can do that! |
It's a little-known fact that Archimedes' original proof and calculations on the circle constant were not of π, i.e. the ratio of circumference to diameter, but of the ratio of circumference to radius, since the radius is the actual defining characteristic of the circle. It is therefore perplexing that he would then proceed to use π as the basis for many further proofs, a tradition carried forward by Leonard Euler.
Nonetheless, this isn't a math history lesson, just a very minor patch to rectify said history. The symbol τ has been promoted in recent years to represent the ratio mentioned (equal to 2π), having a variety of practical, aesthetic, and pedagogical benefits. If anyone is still curious as to why this is an issue at all, I encourage reading the Tau Manifesto at http://tauday.com, although I would be happy to answer questions myself.