Re: Sine and Cosine Accuracy on AMD64 and Pentium 4



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
.



Relevant Pages

  • Re: need help with operations stability
    ... > and I need some references where can I solve the next problem: ... either PI/2 is wrong or your sin and cos functions are wrong. ... that sin and cos implemented in the intel processors FPU are a little bit ...
    (comp.lang.cpp)
  • Re: Parametric plot with a data file instead of functions.
    ... my sin and cos functions come from a 3-column data file. ... I am not quite sure what you mean by "sin and cos functions come from ... If you want to plot the cos of column 2 versus the sin of column one, ...
    (comp.graphics.apps.gnuplot)
  • Re: Combining Functions
    ... request, I have got to the part where i have to program the equations ... and i cant seem to get them to link together. ... enters his radians i was to link to a sin x function to calculate the ... There should be no need to program sin and cos functions yourself. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Tough problem...
    ... The sin and cos functions become inaccurate when ... I'm no expert here, and I dont quite get where the i comes from, but ...
    (borland.public.delphi.language.basm)