public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* Results of cos(pi/2) tests are dependent on error rounding pi/2 to a type.
@ 2013-04-11 12:59 Carlos O'Donell
  2013-04-11 17:44 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Carlos O'Donell @ 2013-04-11 12:59 UTC (permalink / raw)
  To: GNU C Library, libc-ports

Community,

I've recently fixed the cos(pi/2) tests to expect the correct
result from the rounding of pi/2. The tests previously expected
cos(M_PI_2l) to return 0.0, but this is naive. The actual answer
is a non-zero value almost equal to the error in rounding pi/2
to the floating point representation.

The first derivitive of cos(pi/2) is ~1, therefore any error
in pi/2 has a direct and linear effect on the result of the answer
either causing it to be slightly more than 0 or slightly less than
zero. The exact answer to cos(pi/2) is highly dependent on the type
used.

I've tried to take into account all of the types, but in the event
that I've made a mistake please come to me and I'll help fix it.

Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Results of cos(pi/2) tests are dependent on error rounding pi/2 to a type.
  2013-04-11 12:59 Results of cos(pi/2) tests are dependent on error rounding pi/2 to a type Carlos O'Donell
@ 2013-04-11 17:44 ` Andreas Schwab
  2013-04-12  2:22   ` Carlos O'Donell
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2013-04-11 17:44 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: GNU C Library, libc-ports

I'm getting this result on ppc for long double:

Failure: Test: cos (pi/2) == 1.082856673921913968223746169860580e-32
Result:
 is:          1.08285667392191396822e-32   0x1.c1cd129024e088a67cc7p-107
 should be:   1.08285667392191396822e-32   0x1.c1cd129024e088a67cc7p-107
 difference:  5.71253355584909492648e-62   0x1.78000000000000000000p-204
 ulp       :  376.0000
 max.ulp   :  0.0000
Maximal error of `cos'
 is      : 376 ulp
 accepted: 1 ulp
Failure: Test: sincos (pi/2, &sin_res, &cos_res) puts 1.082856673921913968223746169860580e-32 in cos_res
Result:
 is:          1.08285667392191396822e-32   0x1.c1cd129024e088a67cc7p-107
 should be:   1.08285667392191396822e-32   0x1.c1cd129024e088a67cc7p-107
 difference:  5.71253355584909492648e-62   0x1.78000000000000000000p-204
 ulp       :  376.0000
 max.ulp   :  0.0000
Maximal error of `sincos'
 is      : 376 ulp
 accepted: 1 ulp

Filed as PR15359.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Results of cos(pi/2) tests are dependent on error rounding pi/2 to a type.
  2013-04-11 17:44 ` Andreas Schwab
@ 2013-04-12  2:22   ` Carlos O'Donell
  0 siblings, 0 replies; 3+ messages in thread
From: Carlos O'Donell @ 2013-04-12  2:22 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: GNU C Library, libc-ports

On 04/11/2013 01:44 PM, Andreas Schwab wrote:
> I'm getting this result on ppc for long double:
> 
> Failure: Test: cos (pi/2) == 1.082856673921913968223746169860580e-32
> Result:
>  is:          1.08285667392191396822e-32   0x1.c1cd129024e088a67cc7p-107
>  should be:   1.08285667392191396822e-32   0x1.c1cd129024e088a67cc7p-107
>  difference:  5.71253355584909492648e-62   0x1.78000000000000000000p-204
>  ulp       :  376.0000
>  max.ulp   :  0.0000
> Maximal error of `cos'
>  is      : 376 ulp
>  accepted: 1 ulp
> Failure: Test: sincos (pi/2, &sin_res, &cos_res) puts 1.082856673921913968223746169860580e-32 in cos_res
> Result:
>  is:          1.08285667392191396822e-32   0x1.c1cd129024e088a67cc7p-107
>  should be:   1.08285667392191396822e-32   0x1.c1cd129024e088a67cc7p-107
>  difference:  5.71253355584909492648e-62   0x1.78000000000000000000p-204
>  ulp       :  376.0000
>  max.ulp   :  0.0000
> Maximal error of `sincos'
>  is      : 376 ulp
>  accepted: 1 ulp
> 
> Filed as PR15359.

Could you print the following for me?

printf ("%.100000g\n", (long double)(M_PIl/2.0L));

The most likely scenario is that I lost digits of precision when using only %.100Le.

I'm trying to get my hands on a fast ppc box to test stuff on.

Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-12  2:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 12:59 Results of cos(pi/2) tests are dependent on error rounding pi/2 to a type Carlos O'Donell
2013-04-11 17:44 ` Andreas Schwab
2013-04-12  2:22   ` Carlos O'Donell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).