τ (tau) in mathematics is a constant equal to the ratio of a circle's circumferance to its radius.
You may be more familiar with its little brother: π (pi), equal to the ratio of a circle's circumferance to its diameter.
So you may be asking yourself then. Isn't τ just 2π?
Well.. yes.
But that is more usefull than you think! And yet, many languages have not yet included it in their standard libraries!
So when would one use τ?
Well everywhere one would use 2π!
Take the following code sample:
double calculate_circumference(double radius)
{
return 2 * PI * radius; // my fingers hurt :(
}
Aren't your fingers hurting from just looking at the amount of multiply symbols in there? Thats two seperate buttons! For one character!
Now take a look at this:
double calculate_circumference(double radius)
{
return TAU * radius; // I feel refreshed :D
}
Isn't that just more pleasing to the eyes? :3
Okay but now a more usefull example. Say you want to convert degrees into radians. Most sources would tell you to do the following:
double degrees_to_radians(double degrees)
{
return degrees * PI / 180; // 180????
}
Now when you first come across this you might rightfully have some questions. What the hell is 180? Where did that come from?
This is when you are told: "why it's 360 ⋅ 12 of course! 360 being the degrees of a full rotation! We half it because π is equal to the ratio of a circle's circumferance to its diameter!"
But now observe: The humble τ.
double degrees_to_radians(double degrees)
{
return degrees * TAU / 360; // Oh 360! As in a full rotation!
}
Doesn't that just make more inherent sense?!
If you want more convincing examples from people who know what they are talking about, feel free to read the Tau Manifesto: https://www.tauday.com/tau-manifesto
Sadly, not every programming language is kind enough to offer such conviniences. If you are an unfortunate soul stuck with with one of those languages this can easily be fixed by adding it as a constant yourself like so:
#define TAU 6.28318530717958647692528676655900577
Would you rather use a language that provides this by itself? Fret not! Below I have written a comprehensive list of which languages do and do not provide this lovely constant!
Ada does not have a τ constant and I could not find any proposals to add it..
C does not have a τ constant. But it doesn't have a π constant either, so I feel it gets a pass.
C++ does not have a τ constant. There is a perposal to add one to std::numbers from 2022.
https://lists.isocpp.org/std-proposals/2022/03/3642.phpClojure does not have a τ constant and I could not find any proposals to add it..
D does not have a τ constant and I could not find any proposals to add it.
Dart does not have a τ constant and I could not find any proposals to add it.
Go does not have a τ constant. There was a proposal to add it in 2020, but it was rejected.
https://github.com/golang/go/issues/40663Javascript does not have a τ constant. There was a proposal on esdiscuss.org, and apperently it was brought up in a TC39 meeting. In the end they decided against adding it because it was not well-known enough.
https://esdiscuss.org/topic/math-tauWhilst not in the base language, it exists in the JuliaMath package Tau.jl. Which also provides Tau veriants of sin, cos, sincos, cispi and mod2pi.
https://github.com/JuliaMath/Tau.jlKotlin does not have a τ constant. Whilst is was briefly discussed in the kotlin forums as an addition to kotlin.math, it was never made an official proposal.
https://discuss.kotlinlang.org/t/adding-kotlin-math-tau/17967/8Lua does not have a τ constant and I could not find any proposals to add it.
MATLAB does not have a τ constant and I could not find any proposals to add it.
OCaml does not have a τ constant and I could not find any proposals to add it.
Perl does not have a τ constant and I could not find any proposals to add it.
PHP does not have a τ constant and I could not find any proposals to add it.
R does not have a τ constant and I could not find any proposals to add
it. It does have Kendall's Tau which is also named tau(), which caused some confusion.
Raku supports both the ASCII tau term and the literal τ
symbol itself as built-in terms.
Ruby does not have a τ constant. A perposal was made 10 years ago but was rejected, with the stated intention to add it "after (and only after) it became time-proven major,".
https://bugs.ruby-lang.org/issues/4897Scala does not have a τ constant and I could not find any proposals to add it. This is an odd case, since it usually forwards all the symbols that Java has, and Java has had τ since Java 19.
Swift does not have a τ constant. Whilst is was briefly discussed in the as an issue in github, it was rejected as an addition to the language. Maintainer stephentyrone had this to say: "τ is an entertaining novelty. It is not meaningfully better or more correct than π. Why not provide both so that users can choose? Because then everyone who reads τ has to scratch their head for a minute and go down a rabbit hole of YouTube videos. If you want to use it in your own code, it is trivial to define"
https://github.com/apple/swift-numerics/issues/89