[issue31630] math.tan has poor accuracy near pi/2 on OpenBSD

Tim Peters report at bugs.python.org
Mon Oct 2 14:39:23 EDT 2017


Tim Peters <tim at python.org> added the comment:

If someone opens a bug report with OpenBSD, or just for us to get more info, it could be useful to have a larger universe of troublesome tan inputs to stare at.  So the attached tanny.py supplies them, testing all inputs within 100 ulps of math.pi/2 (or change N=100 to whatever you like).

There are no failures on my 64-bit Win10 3.6.1.

The "correct" answers are computed by using mpmath.tan() set to 200 mantissa bits, then rounding back to 53 bits.  These all match the results from my dirt-dumb decimal tan() rounded back, but it's better to trust a widely-used package.

Of course mpmath needs to be installed ("pip install mpmath" works fine):

    http://mpmath.org/

Nothing else is needed (while mpmath will exploit gmpy if it's installed, by default it sticks to pure Python code).

----------
Added file: https://bugs.python.org/file47183/tanny.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31630>
_______________________________________


More information about the Python-bugs-list mailing list