Bug 20490 - cos is broken for many argument values
Summary: cos is broken for many argument values
Status: RESOLVED DUPLICATE of bug 20357
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.23
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-19 01:13 UTC by M Welinder
Modified: 2016-08-22 17:19 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2016-08-19 00:00:00
fweimer: security-


Attachments
Source (435 bytes, text/x-csrc)
2016-08-19 11:25 UTC, M Welinder
Details
Source, after -E (9.70 KB, text/x-csrc)
2016-08-19 11:27 UTC, M Welinder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description M Welinder 2016-08-19 01:13:19 UTC
Gnumeric's test suite fails badly because libc's implementation of cos
is completely broken.  In the following cases, a value near 1 is produced
while the expected value is near 0 as shown.

To be clear: this isn't a matter of being a little bit off.  The results
are completely wrong.  FWIW, my remaining 20k test cases as well as 20k
test cases for sin are correct to the last bit.  (And these test cases
are all from crlibm.)



cos(1.56897934354514)	0.0018169822499879413
cos(1.57037711629437)	0.0004192104882527396
cos(1.57039030076639)	0.0004060260173532676
cos(1.57038734145267)	0.00040898533082718385
cos(1.57032382985257)	0.0004724969247491758
cos(1.57072104158461)	7.528521021193726E-05
cos(1.57070239934268)	9.39274520795412E-05
cos(1.57076411367651)	3.2213118385456906E-05
cos(1.57076933205339)	2.6994741502697283E-05
cos(1.57078730132002)	9.025474872298193E-06
cos(1.57079163285142)	4.693943473288029E-06
cos(1.57078959045523)	6.736339666534601E-06
cos(1.57079060242746)	5.724367440537163E-06
cos(1.57079416327971)	2.1635151908379425E-06
cos(1.57079314183194)	3.184962957203722E-06
cos(1.57079550219782)	8.245970777921096E-07
cos(1.57079585928157)	4.6751333077647875E-07
cos(1.53234363306502)	0.03844321834305775
cos(1.53084652624933)	0.03993917483604875
cos(1.52691385661399)	0.04386838766880302
cos(1.52337859584618)	0.047399963616231014
cos(1.52388665475757)	0.04689246967242659
cos(1.54637691289056)	0.024416987062302536
cos(1.56128512373509)	0.009511059658487897
cos(1.55986436754728)	0.010931741506636932
cos(1.55534663463731)	0.015449077542725311
cos(1.56683423429666)	0.0039620821319713145
cos(1.56419798077001)	0.0065982981450101305
cos(1.56407546523456)	0.006720810963586297
cos(1.56359178279368)	0.007204481675525458
cos(1.56726783015917)	0.003528489313931174
cos(1.56729613789186)	0.003500181756046177
Comment 1 Andreas Schwab 2016-08-19 08:19:01 UTC
I cannot reproduce that.  Please provide a self-contained test case.
Comment 2 M Welinder 2016-08-19 11:25:56 UTC
Created attachment 9457 [details]
Source
Comment 3 M Welinder 2016-08-19 11:27:01 UTC
Created attachment 9458 [details]
Source, after -E
Comment 4 M Welinder 2016-08-19 11:28:33 UTC
The actual output I get is this.  All values should be <0.05

0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999261
0.999202
0.999037
0.998876
0.9989
0.999702
0.999955
0.99994
0.999881
0.999992
0.999978
0.999977
0.999974
0.999994
0.999994
Comment 5 Siddhesh Poyarekar 2016-08-19 12:56:27 UTC
This should be fixed in 2.24 (bug 20357).  Can you please test and verify?
Comment 6 M Welinder 2016-08-19 13:06:39 UTC
Good to hear.  I am not actually setup to test a new libc, so that'll take
a while.
Comment 7 Paul Pluzhnikov 2016-08-22 15:42:18 UTC
FWIW, I am getting:

$ ./a.out
0.00181698
0.00041921
0.000406026
0.000408985
0.000472497
7.52852e-05
9.39275e-05
3.22131e-05
2.69947e-05
9.02547e-06
4.69394e-06
6.73634e-06
5.72437e-06
2.16352e-06
3.18496e-06
8.24597e-07
4.67513e-07
0.0384432
0.0399392
0.0438684
0.0474
0.0468925
0.024417
0.00951106
0.0109317
0.0154491
0.00396208
0.0065983
0.00672081
0.00720448
0.00352849
0.00350018

Using trunk glibc @3f0eedddbe260aad3a7b88051d6aa2b205218aa9 or glibc 2.19-0ubuntu6.9.
Comment 8 Siddhesh Poyarekar 2016-08-22 17:19:57 UTC
Thanks, for confirming Paul, closing as duplicate.  Please file a distribution bug (i.e. in Fedora, Ubuntu, etc) if you need the patch backported to fix gnumeric behaviour.

*** This bug has been marked as a duplicate of bug 20357 ***