Re: Sine and Cosine Accuracy on AMD64 and Pentium 4
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: 22 Jul 2005 20:16:38 -0400
Jack Crenshaw wrote:
> 1) are you sure your value of pi is not part of the problem?
> I have always been told to let the numeric processor set
> its own value, which it knows internally at 80-bit accuracy.
> You can get that value using something like
> pi = 4 * atan(1);
There was recently a long discussion in comp.lang.fortran about
argument reduction for trigonometric functions.
In this case, however, it doesn't depend much at all
on the value of pi.
> 2) It seems to me you're testing the output of the log function > as
much as anything else. Why the logarithmic approach?
The log converts to bits or digits. That also shouldn't have
much effect on the result.
(big snip of complicated program, the most important
statements being...)
>> double s1 = sin(x);
>> double c1 = cos(x);
>> double one = s1 * s1 + c1 * c1;
>> double diff = one - 1.0;
>> final *= one;
For a variety of different values of x.
Note that this does not depend at all on the accuracy of the sin
and cos functions. If sin() returned 1 for all x, and cos() returned
zero you would call it perfectly accurate where it obviously isn't.
There are algorithms where maintaining identities is more important
than accuracy, some of which go by the name symplectic.
A dynamics problem, for example, may find that conservation of energy
is more important than the accurate final positions of the objects.
If one is trying to land an object on mars, the final position is more
important than the accurate kinetic energy.
-- glen
.
- Follow-Ups:
- Re: Sine and Cosine Accuracy on AMD64 and Pentium 4
- From: Henry Spencer
- Re: Sine and Cosine Accuracy on AMD64 and Pentium 4
- References:
- Re: Sine and Cosine Accuracy on AMD64 and Pentium 4
- From: Jack Crenshaw
- Re: Sine and Cosine Accuracy on AMD64 and Pentium 4
- Prev by Date: Re: Implementing a stack-based interpreter
- Next by Date: how to eliminate this left recursion
- Previous by thread: Re: Sine and Cosine Accuracy on AMD64 and Pentium 4
- Next by thread: Re: Sine and Cosine Accuracy on AMD64 and Pentium 4
- Index(es):
Relevant Pages
|
|