## Feature #4897

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

Status: | Assigned | ||
---|---|---|---|

Priority: | Normal | ||

Assignee: | Yukihiro Matsumoto |

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

### History

#### #1 Updated by Simon Baird about 4 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

#### #2 Updated by Simon Baird about 4 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)

#### #3 Updated by Simon Baird about 4 years ago

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

#### #4 Updated by Yusuke Endoh over 3 years ago

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

#### #5 Updated by Martin Dürst over 3 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 :-)

#### #6 Updated by Thomas Sawyer over 3 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.

#### #7 Updated by Koichi Sasada almost 3 years ago

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

#### #8 Updated by Thomas Sawyer over 2 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.

#### #10 Updated by Nobuyoshi Nakada over 2 years ago

Why is it called as τ, half of π?

#### #11 Updated by Matthew Kerwin over 2 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."

#### #12 Updated by Matthew Kerwin over 2 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.

#### #13 Updated by Nathan Zook over 2 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

#### #14 Updated by Harrison Reiser over 2 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

#### #15 Updated by Eric Hodel over 2 years ago

=begin

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)

=end

#### #16 Updated by Thomas Sawyer over 2 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"

#### #17 Updated by Matthew Kerwin over 2 years ago

**File**tau.patch added

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

#### #18 Updated by Eric Hodel over 2 years ago

**Status**changed from*Feedback*to*Assigned***Assignee**set to*Yukihiro Matsumoto*

The patch is fine.

#### #19 Updated by Martin Dürst over 2 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

endrange = 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

#### #20 Updated by Marc-Andre Lafortune over 2 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.

#### #21 Updated by David MacMahon over 2 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

On Feb 26, 2013, at 9:54 PM, drbrain (Eric Hodel) wrote:

Issue #4897 has been updated by drbrain (Eric Hodel).

Status changed from Feedback to Assigned

Assignee set to matz (Yukihiro Matsumoto)## The patch is fine.¶

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

https://bugs.ruby-lang.org/issues/4897#change-37135Author: sbaird (Simon Baird)

Status: Assigned

Priority: Low

Assignee: matz (Yukihiro Matsumoto)

Category: Joke

Target version: Next MajorFirstly 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.htmlAllow 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.

#### #22 Updated by Matthew Kerwin over 2 years ago

**File**tau.patch added

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

#### #23 Updated by Joseph Lindenberg over 2 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.

#### #24 Updated by Joseph Lindenberg over 2 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.

#### #25 Updated by Eric Hodel over 2 years ago

=begin

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)

=end

#### #26 Updated by Alexey Muranov over 2 years ago

+1

#### #27 Updated by Marc-Andre Lafortune over 2 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.

#### #28 Updated by Simon Baird over 2 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

#### #29 Updated by Simon Baird over 2 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.

#### #30 Updated by Benoit Daloze over 2 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.

#### #31 Updated by Harrison Reiser over 2 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.

#### #32 Updated by Simon Baird about 1 year ago

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

See also:

Best wishes and Happy Tau Day... :)

#### #33 Updated by Simon Baird 2 months ago

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

#### #34 Updated by Kenta Murata about 1 month ago

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