[Python-ideas] Fwd: Trigonometry in degrees

Steven D'Aprano steve at pearwood.info
Mon Jun 11 21:09:25 EDT 2018

```On Mon, Jun 11, 2018 at 01:18:10PM -0700, Chris Barker via Python-ideas wrote:
> On Mon, Jun 11, 2018 at 10:24 AM, Michael Selik <mike at selik.org> wrote:
>
> > Would sind and cosd make Euler's formula work correctly?
>
>
> Not trying to pick on you, but this question shows a key misunderstanding:
>
> There is nothing inherently more accurate in using degrees rather than

Actually there is: using radians, the only "nice" angle that can be
represented exactly is 0. With degrees, we can represent a whole lot of
"nice" angles exactly. "Nice", is of course subjective, but most of us
would recognise that 36° represented as exactly 36.0 is nice but being
*approximately* represented as 0.6283185307179586 is not.

Using radians, we have two sources of rounding error:

- π cannot be represented exactly as a float, so we have to use a
number pi which is ever-so-slightly off;

- plus the usual round-off error in the algorithm;

while using degrees, we only have the second one (since 180° *can* be
represented exactly, as the float 180.0).

And with the degrees implementation, we should be able to use correctly
rounded roots for many of our "nice" angles.

> And every computer math lib I've even seen uses floating point radians for
> trig functions, so unless you're really going to implement trig from
> degrees from scratch

Well that's the whole point of the discussion.

> Oh, and radians are the more "natural" units (in fact unitless) for math,

Degrees are unit-less too. 180° = π radians. That's just a scaling
factor difference.

Unless you're doing symbolic maths, differentiating or integrating trig
functions, or certain geometric formulae which are "neater" in radians

Degrees are simply a much more practical unit of angle for practical
work.

> and the only way that things like the Euler identity work.

Its not the *only* way.

https://math.stackexchange.com/questions/1368049/eulers-identity-in-degrees

> Which is why computational math libs use them.

Actually, more maths libraries than you might guess offer trig functions
in degrees, or scaled by pi, e.g:

https://docs.oracle.com/cd/E19957-01/806-3568/ncg_lib.html

Julia and Matlab provide sind etc, and although I cannot find a
reference right now, I seem to recall the latest revision to the IEEE
754 standard suggesting them as optional functions.

--
Steve
```