Issue #4897 has been updated by marcandre (Marc-Andre Lafortune).

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 to 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.
I don't see a huge downside in increasing this. On the other hand, TAU is so easy to calculate, I would trust that anyone knowing of it's existence would simply define it.
----------------------------------------
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-37154

Author: sbaird (Simon Baird)
Status: Assigned
Priority: Low
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: Next Major


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:

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

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


-- 
http://bugs.ruby-lang.org/