sharkdp / numbat

A statically typed programming language for scientific computations with first class support for physical dimensions and units
https://numbat.dev
Apache License 2.0
1.26k stars 53 forks source link

Constant: tau #581

Closed Keavon closed 1 month ago

Keavon commented 1 month ago

Having the built-in constant tau (equal to 2 * pi) would be very handy for describing the radians in a full circle instead of needing to use 2 * pi in many equations like a circle's circumference.

sharkdp commented 1 month ago

We have tau defined here: https://github.com/sharkdp/numbat/blob/master/numbat%2Fmodules%2Fmath%2Fconstants.nbt#L10-L12

It's currently only available as a Unicode identifier τ, but feel free to add a tau alias.

In the CLI version, you can also type \tau<tab> to have the Unicode character τ inserted.

Keavon commented 1 month ago

Glad to see it's included! I wouldn't have thought to type the Greek letter when pi works. Is there a reason only pi is aliased as such by default? I suppose it doesn't matter that much to me, since this would all be customizable in a custom usage, but I suppose I'm just curious now :)

sharkdp commented 1 month ago

Is there a reason only pi is aliased as such by default?

I probably just wanted to keep the name "tau" free, since it's often used for time-related quantities in physics (e.g. relaxation times).