C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal to add the circle constant "tau" to the list of C++ mathematical constants

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sat, 24 Aug 2024 09:03:35 +0100
On Sat, 24 Aug 2024, 04:53 Robin Savonen SΓΆderholm, <
robinsavonensoderholm_at_[hidden]> wrote:

> I stand a little concerned specifically about "tau" here. Could not "pi_2"
> work just as well? Pi has the same meaning in a broad scope of both
> mathematics and physics fields, but "tau" on the other hand may mean a
> number of things.
>

As a constant in std ::numbers though?

It's apparently sometimes used for the golden ratio, but we have phi for
that.

Does it matter that it's used for 300 in
https://en.wikipedia.org/wiki/Greek_numerals ?

We already have e and phi which are used for various terms in other
contexts, but as members of std::numbers they're the well known constants.
That's what namespaces are for.

// Robin
>
> On Sat, Aug 24, 2024, 01:46 Jonathan Wakely via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>>
>>
>> On Sat, 24 Aug 2024, 00:26 Aaron Franke via Std-Proposals, <
>> std-proposals_at_[hidden]> wrote:
>>
>>> Hello ISO standards mailing list members,
>>>
>>> As of C++20, ISO C++ has a collection of useful mathematical constants
>>> in the numerics library:
>>> https://en.cppreference.com/w/cpp/numeric/constants
>>>
>>> However, there is an important constant missing: The circle constant
>>> "Tau", symbol "𝜏", with a value of 2*πœ‹ or about
>>> 6.283185307179586476925286766559...
>>>
>>> I have written a proposal document below, I would greatly appreciate for
>>> feedback on this and will do whatever I can to help move it forward. The
>>> instructions for submitting a proposal also suggest to include an abstract
>>> cover page, which I think is not necessary given the small scope of this
>>> proposal. If more information is needed, see the link in the "Acknowledgements"
>>> section.
>>>
>>>
>>> Document number: ???
>>> Date: 2024-08-23
>>> Audience: Library Evolution Working Group
>>> Reply-to: Aaron Franke <arnfranke_at_[hidden]>
>>>
>>> I. Table of Contents
>>>
>>> Introduction, Motivation and Scope, Impact On the Standard, Design
>>> Decisions, Technical Specifications
>>>
>>> II. Introduction
>>>
>>> Tau 𝜏 is a mathematical constant representing the ratio of a
>>> circle's circumference to its radius. This is also known as the circle
>>> constant, and is equal to about 6.283185307179586476925286766559... or
>>> exactly 2*πœ‹ or 2*pi, representing one full turn in radians. The value
>>> Pi πœ‹ represents half of the circle constant, it is famous in
>>> mathematics and is already present in the ISO C++ standard.
>>>
>>> III. Motivation and Scope
>>>
>>> The Tau 𝜏 constant allows referring to the full circle constant
>>> with one constexpr value that can be used in place of (2*pi), making many
>>> expressions easier to read, since (2*pi) is so common to see in code.
>>> While Pi is already present in ISO C++, Pi is usually accompanied by a
>>> multiplication by 2, so 2*pi. Math libraries often define a constant for
>>> this value due to how common this is. It makes sense to add the Tau
>>> constant into ISO C++ to make it available for all C++ users, rather than
>>> requiring libraries to define their own constant for this. This constant is
>>> intended to be useful for all users, and is widespread in many programming
>>> languages and libraries, including Java, Python, C#, Nim, Rust,
>>> GDScript, Processing, Crystal, Raku, Zig, and even another ISO language,
>>> Eiffel. Tau is also defined in many libraries and engines such as
>>> Unity, Godot, MathJS, and more.
>>>
>>> IV. Impact On the Standard
>>>
>>> This constant does not depend on anything, and nothing depends on
>>> it. It purely extends the available standard with one additional constant.
>>> It can be implemented in current C++ compilers and libraries, but the goal
>>> here is to put it in the standard along with the other mathematical
>>> constants since Tau is such a common and useful mathematical constant.
>>>
>>> V. Design Decisions
>>>
>>> The only two possible alternative designs are to use a different
>>> name or to not implement the constant. Some languages use "2PI" or
>>> "TWO_PI", but the former starts with a number so it is tricky to use as an
>>> identifier, and it can be confused with another constant in some languages,
>>> "2_PI" or "M_2_PI" in GCC,
>>>
>>
>> That constant is part of glibc, not GCC.
>>
>> This looks good otherwise. I don't think we need a feature test macro,
>> users who need compatibility with older implementations can just use 2*pi.
>>
>>
>> which is 2 divided by pi. The name Tau is unambiguous and is used in
>>> many programming languages, including Java, Python, C#, Nim, Rust, and more
>>> listed above. Therefore the design decision to use the name Tau is
>>> consistent with other languages and libraries.
>>>
>>> VI. Technical Specifications
>>>
>>> The technical specification is to add constants to the standard
>>> library header `<numbers>`
>>> https://en.cppreference.com/w/cpp/header/numbers inside of `namespace
>>> std::numbers {` for `tau_v` via `template<class T> inline constexpr T
>>> tau_v = /* unspecified */;` and `template<floating_point T> inline
>>> constexpr T tau_v<T> = /* see description */;`, and `tau` via `inline
>>> constexpr double tau = tau_v<double>();`. The value in these constants must
>>> be defined by the ISO C++ standard as being the mathematical constant 𝜏
>>> (Tau), also known as the circle constant, and may be noted as being exactly
>>> equal to 2*πœ‹ (or 2*pi), and exactly equal to a circle's circumference
>>> divided by its radius.
>>>
>>> VII. Acknowledgements
>>>
>>> Michael Hartl for "The Tau Manifesto": https://tauday.com/
>>>
>>> VIII. References
>>>
>>> C# System.Math.Tau:
>>> https://learn.microsoft.com/en-us/dotnet/api/system.math.tau
>>> Crystal TAU:
>>> https://crystal-lang.org/api/1.13.2/Math.html#constant-summary
>>> GDScript TAU:
>>> https://docs.godotengine.org/en/stable/classes/class__at_[hidden]#class-gdscript-constant-tau
>>> Java Math.TAU:
>>> https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Math.html#TAU
>>> Nim TAU: https://nim-lang.org/docs/math.html#TAU
>>> Processing TAU: https://processing.org/reference/TAU.html
>>> Python math.tau:
>>> https://docs.python.org/3/library/math.html#math.tau
>>> Raku TAU: https://docs.raku.org/language/terms#term_tau
>>> Rust TAU:
>>> https://doc.rust-lang.org/stable/std/f64/consts/constant.TAU.html
>>> Zig std.math.tau:
>>> https://github.com/ziglang/zig/blob/master/lib/std/math.zig#L18
>>>
>>>
>>> Thank you for your consideration,
>>>
>>> Aaron Franke
>>>
>>>
>>>
>>> --
>>> Std-Proposals mailing list
>>> Std-Proposals_at_[hidden]
>>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>>
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
>

Received on 2024-08-24 08:04:59