[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#153548: libc6: Results of math functions are sometimes wrong



On Fri, Dec 27, 2002 at 10:47:08 -0500, Lukas Geyer wrote:
> The funny thing about this is that the result is _exactly_ sin(x)
> instead of cos(x).

Yes, I didn't notice that.

> Furthermore, it seems to be a special case, as slightly changing x
> gives correct results.

Yes, this is a special case (difficult to round exactly). And the
problem occurs only in a small interval (something like 0.80 to
0.83). According to one of my test programs:

Error: cos (line 33)
  [arg.]  x = 0.80190127184058835
  [corr]  y = 0.69534156199418473
  [libm]  z = 0.71867942238767868
Error: cos (line 34)
  [arg.]  x = 0.8107741500588278
  [corr]  y = 0.68893751943804493
  [libm]  z = 0.72482073253360613
Error: cos (line 35)
  [arg.]  x = 0.81808070960270574
  [corr]  y = 0.68362323105565981
  [libm]  z = 0.72983510326718326
Error: cos (line 36)
  [arg.]  x = 0.81909979079003903
  [corr]  y = 0.6828791149804222
  [libm]  z = 0.73053139174408888
Error: cos (line 37)
  [arg.]  x = 0.82926610298753134
  [corr]  y = 0.67541714390565444
  [libm]  z = 0.73743588312363018

No problem before line 33 and after line 37.

The errors correspond to the arguments (in binary):
1.1001101010010010110011011011001001011010001011100001E-1
1.1001111100011101110010100001010111100011110001001111E-1
1.1010001011011011011110011000101001110110110101010001E-1
1.1010001101100001000011000011101100110101000100101110E-1
1.1010100010010101100100010001000000000110100011111011E-1

But no problem for
1.1001100011001001100011001100000101110101100111011100E-1
and
1.1011110111000011110110110001101101010000010000010001E-1
for instance.

Regards,

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA



Reply to: