## Feature #4897

### Define Math::TAU and BigMath.TAU. The "true" circle constant, Tau=2*Pi. See http://tauday.com/

**Description**

Firstly please read the Tau Manifesto at http://tauday.com/ . It's quite long but essential to understanding why this is a good idea.

Here is a patch on trunk that implements this:

http://simonbaird.blogspot.com/2011/06/tau-in-ruby.html

Allow me to anticipate and respond in advance to some common objections:

It's easy to define it yourself so why put this in core.

Possibly correct, but I think this is the right thing to do. Tau is important. And it's a pretty small patch.If this constant goes in then pretty soon someone will want every other math constant and there are hundreds of them. (Slippery slope argument).

The circle constant is one of the two most important numbers is mathematics. It's not just another math constant. We already define Pi.

**Files**

**Related issues**

### History

#### Updated by sbaird (Simon Baird) over 8 years ago

Sorry for the too long title. Don't know how to edit. Suggested title:

Define Math::TAU and BigMath.TAU. The "true" circle constant, Tau=2*Pi

#### Updated by sbaird (Simon Baird) over 8 years ago

Direct link to the gist containing my patch:

https://gist.github.com/1029552

Edit: mention this is a patch (pluid61's patch is better though)

#### Updated by sbaird (Simon Baird) over 8 years ago

Edit: particularly http://tauday.com/tau-manifesto

#### Updated by mame (Yusuke Endoh) over 7 years ago

**Category**changed from*core*to*Joke***Status**changed from*Open*to*Feedback*

#### Updated by duerst (Martin Dürst) over 7 years ago

We have discussed this at today's developers' meeting in Akihabara.

We highly doubt that there are many mathematicians, physicists, engineers, and so on, who use τ. Once τ is widely accepted in these communities, we might add it.

Just as a personal comment, I prefer π to τ because I can eat a pie, but not a tau :-)

#### Updated by trans (Thomas Sawyer) over 7 years ago

I'm trying to get used to the idea of eating a pizza taue, myself. :-)

This is the classic chicken and egg situation -- "We'll do it if it's popular", but "It won't get popular unless people do it".

I think Tau=2*Pi is a good idea. So if it were just up to me, I'd add it just to show support. It's a rather tiny and harmless addition.

#### Updated by ko1 (Koichi Sasada) about 7 years ago

**Target version**changed from*2.0.0*to*Next Major*

#### Updated by trans (Thomas Sawyer) almost 7 years ago

Could this patch be applied now? As previously said, it's a good thing to show support for and it's a rather tiny and otherwise harmless addition.

#### Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

Why is it called as τ, half of π?

#### Updated by phluid61 (Matthew Kerwin) almost 7 years ago

nobu (Nobuyoshi Nakada) wrote:

Why is it called as τ, half of π?

It's actually two of π. The reason for the name is justified here: http://tauday.com/tau-manifesto#sec:one_turn

In summary: tau is the first letter of the Greek word "tornos" (lathe), which is the root of the English word "turn;" and the tau constant (2*PI) is the ratio of a circle's radius to its circumference (i.e. one __turn__.) Also "the horizontal line in each letter suggests that we interpret the “legs” as __denominators__, so that π has two legs in its denominator, while τ has only one. Seen this way, the relationship τ=2π is perfectly natural."

#### Updated by phluid61 (Matthew Kerwin) almost 7 years ago

On 26 February 2013 19:20, nobu (Nobuyoshi Nakada) nobu@ruby-lang.orgwrote:

Why is it called as τ, half of π?

It's actually two of π. The reason for the name is justified here:

http://tauday.com/tau-manifesto#sec:one_turn

In summary: tau is the first letter of the Greek word "tornos" (lathe),

which is the root of the English word "turn;" and the tau constant (2*PI)

is the ratio of a circle's radius to its circumference (i.e. one __turn__.)

Also "the horizontal line in each letter suggests that we interpret the

"legs" as __*denominators__*, so that π has two legs in its denominator,

while τ has only one. Seen this way, the relationship τ=2π is perfectly

natural."

EDIT: apologies for the double-posting. I'm not quite sure how I managed it.

#### Updated by Student (Nathan Zook) almost 7 years ago

Please, just say no. This garbage is one and only thing that has made me really glad that I decided to leave academia. Having to dissuade every crank from this idea would ruin my mood for weeks.

There a large number of excellent candidate constants to be included. There is absolutely no cause to include constants that are power-of-two multiples of each other. You want tau in math? Fine. `module Math ; TAU = 2 * PI ; end`

. Done. Put that in all your files. Move it to your initialization code. Publish a gem. I don't care. But don't waste the time of people who understand that shifting a binary point by 1 really isn't a big deal.

-Math::PI

#### Updated by bug (Harrison Reiser) almost 7 years ago

Wow, such vitriol ! I could point out a correlation between it and your stance on academia, but I would be flying in the face of not only courtesy but also the whole point of all this. I assure you that tau is not a joke, and has everything to do with mere common sense, both in pedagogy and practice (which, as it were, seems to be what many have come to know Ruby for).

While, as you say, not having the full circle constant is "not a big deal" given a simple means to derive it, I would be shocked to learn that any practiced programmer makes use of pi alone more often than 2*pi. For this very reason many libraries for other languages include both constants, not just for coding efficiency but for __runtime__ efficiency. So far, this constant has almost ubiquitously been named TWO_PI (or some variation thereof) simply by convention, but the fact of its prevalence should be enough indication of its __independent usefulness__ (an important distinction, one which I have no intention of debating further, having already been, repeatedly and at length -- see https://en.wikipedia.org/wiki/User:Waldir/Tau for examples).

Now, dynamic languages such as Ruby and Python stand in a unique position. As intuitiveness and coder efficiency are among their primary goals, they indeed have no reason to include a constant named TWO_PI, which would overall detract from these goals. However, a constant named TAU would serve as an indication that this number has some distinction of its own, namely the aforementioned independent usefulness. Therefore if it is to be included at all it should be with conviction rather than the attitude of mere quiet tolerance (as of a vocal minority), as it would indeed stand as a statement to the programming community.

The decision to postpone its addition until recognition spreads further is reasonable, but as trans mentioned it perpetuates the chicken and egg problem. Either way, I hope I have raised sufficient objection to categorizing this issue as a "Joke".

-bug

#### Updated by drbrain (Eric Hodel) almost 7 years ago

Despite all the argument for this constant, nobody has provided a patch, so it seems like a joke.

Runtime performance of a constant lookup is 3% +/- 1.2% faster than multiplying a float by 2 on my machine over 20 million multiplications. 3% for a built-in constant doesn't seem like a big deal.

I don't trust a wikipedia user page as a reference, it doesn't go through the same vetting process as a regular wikipedia page.

Benchmarks:

$ cat bm.rb require 'benchmark' module Math TAU = 2*Math::PI end range = Float::EPSILON..10.0 N = Integer ARGV.shift case ARGV.shift when 'tau' then puts Benchmark.measure { N.times do 2 * Math::PI * rand(range) end }.real when '2pi' then puts Benchmark.measure { N.times do 2 * Math::TAU * rand(range) end }.real else abort "#{$0} N tau|2pi" end $ for i in `jot 20`; do ruby bm.rb 1_000_000 2pi; done > 2pi.txt $ for i in `jot 20`; do ruby bm.rb 1_000_000 tau; done > tau.txt $ ministat tau.txt 2pi.txt x tau.txt + 2pi.txt +------------------------------------------------------------------------------+ |x xx x + + + + + | |x x x*xxx+ x * x+ * ++x +++ + ++ + +| | |____M_A___|_|___________MA_______________| | +------------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 20 0.486589 0.504393 0.491397 0.49242015 0.0049904288 + 20 0.490699 0.544828 0.506571 0.5073239 0.011828075 Difference at 95.0% confidence 0.0149037 +/- 0.00581011 3.02663% +/- 1.17991% (Student's t, pooled s = 0.00907766)

#### Updated by trans (Thomas Sawyer) almost 7 years ago

Despite all the argument for this constant, nobody has provided a patch, so it seems like a joke.

"Here is a patch on trunk that implements this: http://simonbaird.blogspot.com/2011/06/tau-in-ruby.html"

#### Updated by phluid61 (Matthew Kerwin) almost 7 years ago

drbrain (Eric Hodel) wrote:

Despite all the argument for this constant, nobody has provided a patch, so it seems like a joke.

The gist linked in Comment 2 was a diff/patch, althought it's outdated and no longer applies cleanly. I've attached a new patch (generated using `git diff`

). Please let me know if I'm supposed to generate it with --no-prefix

#### Updated by drbrain (Eric Hodel) almost 7 years ago

**Status**changed from*Feedback*to*Assigned***Assignee**set to*matz (Yukihiro Matsumoto)*

The patch is fine.

#### Updated by duerst (Martin Dürst) almost 7 years ago

Hello Eric,

I'm confused by the code below. First, it uses Math::PI with the 'tau'

option, and Math::TAU with the '2pi' option. Second, even when using

Math::TAU, it includes a multiplication by 2.

Regards, Martin.

On 2013/02/27 14:08, drbrain (Eric Hodel) wrote:

Benchmarks:

$ cat bm.rb require 'benchmark' module Math TAU = 2*Math::PI end range = Float::EPSILON..10.0 N = Integer ARGV.shift case ARGV.shift when 'tau' then puts Benchmark.measure { N.times do 2 * Math::PI * rand(range) end }.real when '2pi' then puts Benchmark.measure { N.times do 2 * Math::TAU * rand(range) end }.real else abort "#{$0} N tau|2pi" end

#### Updated by marcandre (Marc-Andre Lafortune) almost 7 years ago

**Category**changed from*Joke*to*core*

duerst (Martin Dürst) wrote:

Hello Eric,

Second, even when using

Math::TAU, it includes a multiplication by 2.

Right, I'd say the test doesn't say much... Actually, any difference apparently measured has to be meaningless, there's no intrinsic difference in either cases.

For what it's worth:

require 'fruity' module Math TAU = 2 * PI end compare do pi { Math.cos(2 * Math::PI) } tau { Math.cos(Math::TAU) } end # => tau is faster than pi by 50.0% ± 10.0%

I had to call Math.cos, because otherwise just accessing Math::TAU is too difficult to time.

Math currently has 2 constants (PI and E)

I don't see a huge downside in increasing this. On the other hand, TAU is so easy to define, I would trust that anyone knowing of it's existence would simply define it.

#### Updated by david_macmahon (David MacMahon) almost 7 years ago

I vote -1 on this idea because the name "TAU" is used in a number of fields to represent a wide variety of things:

For example, tau as also used as a constant representing the golden ratio (1.618...).

The names "PI" and "E" are used far more consistently across fields. Giving special preference to one (proposed!) use of the name "TAU" seems unfair to the other (established!) uses.

How about making a "twopi" gem that defines Math::TAU and BigMath.TAU? If it is as useful as its proponents claim, it will undoubtedly become a very popular gem and the public outcry to add it to the core of the language will be deafening.

Dave

#### Updated by phluid61 (Matthew Kerwin) almost 7 years ago

I just noticed a stupid typo in the patch I submitted. Sorry.

#### Updated by JosephLindenberg (Joseph Lindenberg) almost 7 years ago

The Processing programming language recently added TAU:

http://code.google.com/p/processing/source/browse/trunk/processing/core/src/processing/core/PConstants.java

It does seem to be showing up more and more frequently. Here's a recent SAMS book where the author uses it in his examples:

http://books.google.com/books?id=BFda3Z71Y5YC&printsec=frontcover

I'm in favor of adding TAU. It's definitely not the same as having a bunch of multiples and submultiples of a constant. In fact, you really could say that right now, we have the submultiple-of-a-constant HALF_TAU, just under a different name.

#### Updated by JosephLindenberg (Joseph Lindenberg) almost 7 years ago

david_macmahon (David MacMahon) wrote:

For example, tau is also used as a constant representing the golden ratio (1.618...).

No, not anymore. φ (phi) is used for that now.

#### Updated by drbrain (Eric Hodel) almost 7 years ago

Martin, you are right. With a corrected benchmark there is an 8.5% +/- 1.2% improvement:

x tau.txt + 2pi.txt +--------------------------------------------------------------------------+ |xx x x + + + + | |xx x xxxx x x x + + + + + +++ + + + ++ + + +| | |______A_____| |________MA_________| | +--------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 20 0.526745 0.557717 0.535967 0.5353094 0.0073255609 + 20 0.562776 0.60921 0.579785 0.5810366 0.011508619 Difference at 95.0% confidence 0.0457272 +/- 0.00617423 8.5422% +/- 1.15339% (Student's t, pooled s = 0.00964656)

#### Updated by marcandre (Marc-Andre Lafortune) almost 7 years ago

drbrain (Eric Hodel) wrote:

Martin, you are right. With a corrected benchmark there is an 8.5% +/- 1.2% improvement:

To be more accurate, you'd have to subtract the time of an empty loop. If you compare 42 * pi with 42 *pi; 42 * pi using your technique, you won't get the expected answer (100%). I get ~50% with your technique.

I should introduce some of the techniques in ministat in my fruity gem.

#### Updated by sbaird (Simon Baird) almost 7 years ago

david_macmahon (David MacMahon) wrote:

I vote -1 on this idea because the name "TAU" is used in a number of fields to represent a wide variety of things:

For example, tau as also used as a constant representing the golden ratio (1.618...).

mhartl addresses this here:

http://tauday.com/tau-manifesto#sec:ambiguous_notation

#### Updated by sbaird (Simon Baird) almost 7 years ago

I don't think the benchmarks are particularly relevant here. We should define Tau because it's important, not for any performance benefit.

#### Updated by Eregon (Benoit Daloze) almost 7 years ago

sbaird (Simon Baird) wrote:

I don't think the benchmarks are particularly relevant here. We should define Tau because it's important, not for any performance benefit.

Indeed.

Although I am not sure of the importance of having TAU. One PI is fine for unit conversions as well as computing the area of a circle. But there are also many cases of 2*PI, which sounds less-than-ideal.

#### Updated by bug (Harrison Reiser) over 6 years ago

Eregon (Benoit Daloze) wrote:

Although I am not sure of the importance of having TAU. One PI is fine for unit conversions as well as computing the area of a circle. But there are also many cases of 2*PI, which sounds less-than-ideal.

They are more common than you would think. Finding the area of circles is actually relatively specialized, in comparison with, for example, circular sectors (1/2 * angle * r^{2),} for which the circle formula is a special case: 1/2 * tau * r^{2} = pi * r^{2.} The use of pi is an aesthetic optimization, not representative of any underlying geometric relationship. (However, the use of pi in runtime optimization is still applicable for such special cases.)

This mere coincidence becomes even more obvious when looking at the derivation of the above formulae, and as with everything discussed heretofore, is already discussed in the Tau Manifesto. Incidentally, I recommend anyone still wavering to read it for the benefit of making more informed opinions.

#### Updated by sbaird (Simon Baird) over 5 years ago

Since today is 6/28, here's a pull request on trunk:

See also:

Best wishes and Happy Tau Day... :)

#### Updated by sbaird (Simon Baird) over 4 years ago

I'm a bit late, but here it is rebased for Tau Day 2015:

#### Updated by mrkn (Kenta Murata) over 4 years ago

As I wrote in https://github.com/ruby/ruby/pull/644#issuecomment-123082639, I closed the pull-request for the present time.

#### Updated by sbaird (Simon Baird) over 3 years ago

This may be of interest: Guido van Rossum recently reopened the Python version of this request and is going to add tau to Python. See https://bugs.python.org/issue12345 .

#### Updated by nobu (Nobuyoshi Nakada) about 3 years ago

At the developers' meeting this week, mrkn suggested `TWO_PI`

instead.

#### Updated by duerst (Martin Dürst) about 3 years ago

On 2016/10/14 13:35, RRRoy BBBean wrote:

Would such an interconnected system be packaged as a bunch of individual

gems, or is there some higher-level packaging concept than the Ruby gem?I personally think gems are best when kept as small as possible, highly

cohesive and highly coherent. But that creates a secondary problem? How

to organize larger units of reusable code? I don't know.

It's easy. Gems can depend on other gems. So we can have some highly

cohesive and highly coherent gems at the bottom, and then other, more

application-oriented gems that pull the necessary basic gems together.

This can be done on more and more levels if necessary.

Composition is a great concept, and applying it recursively is even better.

Regards, Martin.

#### Updated by sbaird (Simon Baird) about 3 years ago

Nobuyoshi Nakada wrote:

At the developers' meeting this week, mrkn suggested

`TWO_PI`

instead.

I don't think TWO_PI would be very useful since it misses the main point of tau, which is that tau is the correct circle constant, (and pi is a 2000 year old blunder)[1]. If you consider this diagram [2] with TWO_PI in place of tau, then it loses its meaning.

Defining HALF_TAU could be useful though. ;)

[1] Of course not everyone agrees on this, but http://tauday.com/tau-manifesto is quite convincing IMO

#### Updated by shyouhei (Shyouhei Urabe) about 3 years ago

Just to add my POV:

I'm a complete amateur in pure Mathematics. To me who is an outsider of academia, I can't say we should accept or reject this request right now. All I can say is it seems not widely used in papers for some reason I don't know. It's not clear to me wether the constant τ is just yet to receive wider acceptance because it's relatively young, or is actively receiving low marks from academic community. I'm just not sure.

This constant is a constant (by nature), so once introduced in ruby it's highly expected to stay defined forever. Because of this property I'm afraid of wrong decision. Is it really safe we add this? In order to make this sure I think we need either more time, or an expert's counsel, or maybe both.

#### Updated by sbaird (Simon Baird) about 3 years ago

See also https://github.com/jneen/math-tau .

#### Updated by matz (Yukihiro Matsumoto) about 3 years ago

**Status**changed from*Assigned*to*Rejected*

For the time being, use `math-tau`

gem.

I will add it after (and only after) it became time-proven major, probably due to Python's tau.

Matz.

#### Updated by naruse (Yui NARUSE) over 2 years ago

**Related to***Feature #13694: Add Tau constant to Math*added