calculation accuracy



Hi all,

I'm pretty new to fortran programming. I'm having a problem with the
accuracy of a simple computation:

I want to compute: sin(2*PI*100*0.1) but the answer that I'm getting
in fortran is quite a bit different than what I get in excel.


This is a sample program that I have:

PROGRAM test

REAL(8) :: A, B
DOUBLE PRECISION PI_D

PI_D = 3.1415927D0

A = sin(2.0*PI_D*10)
B = sin(2.0*PI_D*100.0*0.10)

PRINT *, A, B

END PROGRAM test

This program gives me A = 9.282041351020012E-007 and B =
1.864471717675201E-006. Why is there such a big difference? The answer
that excel gives is 9.28204135102001E-07.

.



Relevant Pages

  • Re: calculation accuracy
    ... I'm pretty new to fortran programming. ... in fortran is quite a bit different than what I get in excel. ... END PROGRAM test ... There is a significant difference between 0.1 and 0.1D0. ...
    (comp.lang.fortran)
  • Re: calculation accuracy
    ... DOUBLE PRECISION:: PI_D ... END PROGRAM test ... I'm pretty new to fortran programming. ... in fortran is quite a bit different than what I get in excel. ...
    (comp.lang.fortran)
  • Re: calculation accuracy
    ... I'm pretty new to fortran programming. ... in fortran is quite a bit different than what I get in excel. ... that I often use, double precision is real. ...
    (comp.lang.fortran)
  • Re: calculation accuracy
    ... DOUBLE PRECISION:: PI_D ... END PROGRAM test ... in fortran is quite a bit different than what I get in excel. ...
    (comp.lang.fortran)