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

2018-07-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: After fixing platform.libc_ver() in issue26544 we can use it for conditional skipping this assertion depending on the libc version. -- versions: +Python 3.8 ___ Python tracker

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

2017-11-20 Thread Tim Peters
Tim Peters added the comment: I have no opinion about any version of xxxBSD, because I've never used one ;-) If current versions of those do have this failure, has anyone opened a bug report on _their_ tracker(s)? I've seen no reason yet to imagine these failures are a fault in Python. ---

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

2017-11-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Do you consider the recent stable releases of OpenBSD 6.1 (April 11, 2017) and NetBSD 7.1 (March 11, 2017) out-of-date platforms? The develop version of NetBSD 8 has the same failure. -- ___ Python tracker

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

2017-11-19 Thread Tim Peters
Tim Peters added the comment: Best I can tell, the fdlibm 5.3 on netlib was released in 2002, and essentially stopped existing as a maintained project then. Everyone else copied the source code, and made their own changes independently ever since :-( At least the folks behind the Julia lang

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

2017-11-18 Thread Stefan Krah
Stefan Krah added the comment: I found an unused i386 box with OpenBSD and Linux (so no VM): A C program with tan(1.5707963267948961) is wrong on both systems. fdlibm (directly from netlib.org) is correct on both systems. Both OS versions are relatively old, so I cannot file an upstream issu

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

2017-11-18 Thread Stefan Krah
Stefan Krah added the comment: Tim has mentioned the high quality of fdlibm, and indeed I cannot reproduce the issue: wget -r http://www.netlib.org/fdlibm/ Then build libm with or without optimizations, with or without -m32, gcc or clang. Then compile a C program that calls tan(1.5707963

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

2017-11-02 Thread Mark Dickinson
Mark Dickinson added the comment: > I'd be surprised if sin(x)/cos(x) were materially better. Yep. I made the same assumption as you, but then "realised" that to get to the tan tests, we must already have passed all the cos tests, so cos must be okay. I thought I'd written cos tests near pi/

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

2017-11-01 Thread Tim Peters
Tim Peters added the comment: Oops! I mixed up `sin` and `cos` in that comment. If it's argument reduction that's broken, then for x near pi/2 cos(x) will be evaluated as -sin(x - pi/2), which is approximately -(x - pi/2), and so error in argument reduction (the "x - pi/2" part) will show u

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

2017-11-01 Thread Tim Peters
Tim Peters added the comment: Since fdlibm uses tan(x) ~= -1/(x-pi/2) in this range, and the reciprocals of the bad results have a whole of bunch of trailing zero bits, my guess is that argument reduction (the "x-pi/2" part) is screwing up (losing bits of pi/2 beyond the long string of initia

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

2017-11-01 Thread Stefan Krah
Stefan Krah added the comment: On Wed, Nov 01, 2017 at 06:17:44PM +, Mark Dickinson wrote: > I'm really reluctant to (even conditionally) skip the test, because it's > doing exactly what it's designed to do, namely detecting and reporting that > Python is giving poor results in this corner

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

2017-11-01 Thread Mark Dickinson
Mark Dickinson added the comment: The big mystery for me is not "Why this is occurring in the first place?" but "What should we do about it?" I'm really reluctant to (even conditionally) skip the test, because it's doing exactly what it's designed to do, namely detecting and reporting that Py

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

2017-10-31 Thread Stefan Krah
Stefan Krah added the comment: On Tue, Oct 31, 2017 at 07:32:00PM +, Serhiy Storchaka wrote: > >>From 4 considered results the tests are failed on gcc 4.2.1, 4.7.2, 4.8.5, > >>but are passes on gcc 7.2.0. I suppose this is gcc or libc bug fixed in > >>recent versions. 4.7.3 passes here wi

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

2017-10-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: >From 4 considered results the tests are failed on gcc 4.2.1, 4.7.2, 4.8.5, but >are passes on gcc 7.2.0. I suppose this is gcc or libc bug fixed in recent >versions. -- ___ Python tracker

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

2017-10-31 Thread Stefan Krah
Stefan Krah added the comment: So the big mystery is still: https://mail.python.org/pipermail/python-dev/2017-October/149880.html Could be a Linux router with some alternative libc ... -- ___ Python tracker

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

2017-10-31 Thread Mark Dickinson
Mark Dickinson added the comment: > Seems the first result is calculated at compile time Makes sense. Last time I looked, gcc uses MPFR for the compile-time calls, so I'd expect those to be correctly rounded. -- ___ Python tracker

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

2017-10-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I have got both (!) results in the same binary on NetBSD (gcc 4.8.5). tan(1.57079632679489611) = 1978937966095219.00 tan(0x1.921fb54442d16p+0) = 0x1.c1f559a01adccp+50 tan(1.57079632679489611) = 1978945885716843.00 tan(0x1.921fb54442d16p+0) = 0x1.c1f5c

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

2017-10-29 Thread Stefan Krah
Stefan Krah added the comment: Also, does this occur in a VM on on the bare metal or both? What leaves me puzzled is that I cannot reproduce the Linux x86 report with almost the exact same compiler. But I'm on x64 and use -m32. -- ___ Python tracker

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

2017-10-29 Thread Tim Peters
Tim Peters added the comment: BTW, has anyone tried running a tiny C program on these platforms to see what tan(1.5707963267948961) delivers? The kind of code fdlibm uses is sensitive not only to compiler (mis)optimization, but also to stuff like how the FPU's "precision control" is set, and

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

2017-10-29 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- components: +Tests -Extension Modules title: math.tan has poor accuracy near pi/2 on OpenBSD -> math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD versions: +Python 2.7, Python 3.6, Python 3.7 ___ Python tracke

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

2017-10-29 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +4138 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-

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

2017-10-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is the same result on NetBSD 7.1. -- ___ Python tracker ___ ___ Python-bugs-list mailing l

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

2017-10-17 Thread Jeff Allen
Change by Jeff Allen : -- nosy: +jeff.allen ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

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

2017-10-16 Thread Tim Peters
Tim Peters added the comment: On 16 Oct 2017, exactly the same test failures were reported on python-dev: https://mail.python.org/pipermail/python-dev/2017-October/149880.html >From the test output posted there: """ == CPython 3.6.3 (default, Oct 16 2017, 14:42:21) [GCC 4.7.2] == Linux-3.2.0-

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

2017-10-02 Thread Tim Peters
Tim Peters added the comment: When Sun was developing fdlibm, I was (among other things) working on a proprietary libm for Kendall Square Research. I corresponded with fdlibm's primary author (KC Ng) often at the time. There's no way he would have left errors this egregious slip by, or negl

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

2017-10-02 Thread Tim Peters
Tim Peters added the comment: Thanks for tanny-openbsd.txt, Serhiy! OpenBSD didn't get anywhere close to the best answer on any of those 201 inputs. I was hoping we could, e.g., test something a little more removed from pi/2 - but even its best cases in this range are hundreds of millions o

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

2017-10-02 Thread Serhiy Storchaka
Change by Serhiy Storchaka : Added file: https://bugs.python.org/file47184/tanny-openbsd.txt ___ Python tracker ___ ___ Python-bugs-list mail

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

2017-10-02 Thread Tim Peters
Tim Peters 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=

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

2017-10-01 Thread Tim Peters
Tim Peters added the comment: Ah! So it looks like OpenBSD took its math functions from Sun's fdlibm. I believe wxMaxima does too. That would certainly explain why they give the same answer ;-) So who's right? Using "bigfloats" in wxMaxima and feeding its bigfloat tan() the exact decimal

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

2017-10-01 Thread Stefan Krah
Stefan Krah added the comment: OpenBSD reduces to the range [-pi/4,pi/4]: https://github.com/openbsd/src/blob/master/lib/libm/src/s_tan.c According to the man page on i386: http://man.openbsd.org/FreeBSD-11.0/math.3 "Argument reduction is not performed accurately for huge arguments, r

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

2017-10-01 Thread Tim Peters
Tim Peters added the comment: Of course the relationship is extremely delicate near pi/2. On my Windows Python 3: >>> import math >>> (1.5707963267948961).hex() '0x1.921fb54442d16p+0' >>> math.tan(float.fromhex('0x1.921fb54442d16p+0')) # what the test expects 1978937966095219.0 >>> math.tan(f

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

2017-10-01 Thread Mark Dickinson
Mark Dickinson added the comment: So actually, the cause of the inaccuracy here could be that OpenBSD _is_ using the hardware instructions ... -- ___ Python tracker ___ __

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

2017-10-01 Thread Mark Dickinson
Mark Dickinson added the comment: I'm fairly sure most modern OSs on x86-64 use software implementations of sin, cos and tan. At least, I hope so: the x87 hardware versions are notoriously inaccurate: https://randomascii.wordpress.com/2014/10/09/intel-underestimates-error-bounds-by-1-3-quinti

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

2017-10-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: I would have thought this would be a straight pass-through to the underlying hardware FPU tan() instruction so that it would give the same answer for the same hardware regardless of O/S. Perhaps we're seeing a software-only implementation (using CORDIC or

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

2017-09-29 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- nosy: +davin ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

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

2017-09-29 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : test_math and test_cmath fail on OpenBSD 6.1. == FAIL: test_testfile (test.test_math.MathTests) -- Traceback (most recent