[Python-ideas] Fwd: Trigonometry in degrees

Nathaniel Smith njs at pobox.com
Tue Jun 12 06:41:11 EDT 2018

On Tue, Jun 12, 2018, 00:03 Stephan Houben <stephanh42 at gmail.com> wrote:

> Hi all,
> I wrote a possible implementation of sindg:
> https://gist.github.com/stephanh42/336d54a53b31104b97e46156c7deacdd
> This code first reduces the angle to the [0,90] interval.
> After doing so, it can be observed that the simple implementation
>   math.sin(math.radians(angle))
> produces exact results for 0 and 90, and a result already rounded to
> nearest for
> 60.

You observed this on your system, but math.sin uses the platform libm,
which might do different things on other people's systems.

> For 30 and 45, this simple implementation is one ulp too low.
> So I special-case those to return the correct/correctly-rounded value
> instead.
> Note that this does not affect monotonicity around those values.

Again, monotonicity is preserved on your system, but it might not be on
others. It's not clear that this matters, but then it's not clear that any
of this matters...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180612/8b04c202/attachment.html>

More information about the Python-ideas mailing list