std.math.TAU

James Fisher jameshfisher at gmail.com
Tue Jul 5 04:31:53 PDT 2011


On Tue, Jul 5, 2011 at 12:15 PM, Steven Schveighoffer
<schveiguy at yahoo.com>wrote:

> On Tue, 05 Jul 2011 04:31:09 -0400, James Fisher <jameshfisher at gmail.com>
> wrote:
>
>  Hopefully this won't be taken as frivolous.  I (and possibly some of you)
>> have been convinced by the argument at http://tauday.com/.  It's very
>> convincing, and I won't rehash it here.
>>
>> The use of τ instead of π will only become really convenient when one does
>> not have to preface everything with "let τ = 2π".
>>
>> For example, in D, in order to think in terms of τ instead of π, one must
>> define `enum real TAU = std.math.PI * 2;`, and possibly also TAU_2, TAU_4,
>> etc.
>>
>> As well as being a typing inconvenience, I also think things are not that
>> easy due to loss of precision (though I'm far from an expert on
>> intricacies
>> of floating point).
>>
>> There is an initiative to add TAU to the Python standard library:
>> http://www.python.org/dev/**peps/pep-0628/<http://www.python.org/dev/peps/pep-0628/>
>>
>> To this end, I suggest adding the constant TAU to std.math, and possibly
>> also TAU_2 as an alias for PI, TAU_4 as an alias for PI_2, TAU_8 as PI_4.
>>
>> In any case, I'd like to know what's necessary in order for me to define
>> these constants without loss of precision.
>> d
>>
>
> I read an article about this recently, it's definitely interesting.  The
> one place where I haven't seen it mentioned is what happens when you want
> the area of a circle, since that necessarily involves the radius.  I'd guess
> you'd have to use τ/2 * r^2, but even then, that's one formula vs. the rest.
>  It's probably a good tradeoff.  I can definitely see the advantage when
> using radians.  Never thought I'd have to re-learn trig again...
>
> One thing I like about Pi vs Tau is that it cannot be mistaken for a normal
> character.
>
> I'm not a floating point expert, but I would expect since floating point is
> stored in binary, dividing or multiplying by 2 loses no precision at all.
>  But I could be wrong...
>

Sorry, I didn't state this very clearly.  Multiplying the approximation of
PI in std.math should yield the exact double of that approximation, as it
should just involve increasing the exponent by 1.  However, [double the
approximation of the constant] is not necessarily equal to [the
approximation of double the constant].  Does that make sense?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110705/55546477/attachment-0001.html>


More information about the Digitalmars-d mailing list