Hacker News new | ask | show | jobs
by marginalia_nu 948 days ago
To be fair, thse functions aren't defined for physical quantities.

As a physicist, if you ever see units on the parameter to a trigonmetric function, you can be fairly certain something is wrong.

You can derive this from how e.g. cos(x) can be written as a polynomial series, something like 1 - x^2 + whatever; and since 1 and x^2 would have different units if x is anything but unitless, you've goofed.

That's a big reason why units are used in calculations in the first place. They basically act as a sort of checksum for your calculations.

2 comments

> As a physicist, if you ever see units on the parameter to a trigonmetric function, you can be fairly certain something is wrong.

Exactly. Which is why trigonometric functions in Numbat have the signature

  cos(x: Scalar) -> Scalar
and only take quantities as arguments that are implicitly convertible to a scalar, like 'cos(pi / 3)', 'cos(30 deg)' or 'cos(0.5 turn)'.

Whether or not angles should be considered dimensionless is actually a matter of academic dispute. If you want to know more, take a look at https://github.com/sharkdp/numbat/pull/167 and the references therein.

Radians vs degrees?
For radians, we can note that the length of a circle segment is rα, where r is the radius and α is the angle, where both the radius and circle segment have dimensions length; then we must infer that α is dimensionless.

Degrees follow a similar argument.

Radians, gradians, degrees, minutes, seconds, thirds, revolutions are all ways of dividing up a circle