[Python-ideas] Fwd: Trigonometry in degrees

Steven D'Aprano steve at pearwood.info
Sat Jun 16 09:27:24 EDT 2018


On Thu, Jun 14, 2018 at 01:44:34PM -0500, Tim Peters wrote:
> I should note that numeric code "that works" is often much subtler than it
> appears at first glance.  So, for educational purposes, I'll point out some
> of what _wasn't_ said about this crucial function:
[...]


Thanks Tim!

Reading your digressions on the minutia of floating point maths is 
certainly an education. It makes algebra and real-valued mathematics 
seem easy in comparison.

I still haven't got over Mark Dickinson's demonstration a few years 
back that under Decimal floating point, but not binary, it is possible 
for the ordinary arithmetic average (x+y)/2 to be outside of the 
range [x, y]:


py> from decimal import getcontext, Decimal
py> getcontext().prec = 3
py> x = Decimal('0.516')
py> y = Decimal('0.518')
py> (x + y) / 2
Decimal('0.515')




-- 
Steve


More information about the Python-ideas mailing list