calculation accuracy
- From: "Ben" <bkenney@xxxxxxxxx>
- Date: 27 Mar 2007 15:02:05 -0700
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.
.
- Follow-Ups:
- Re: calculation accuracy
- From: John Campbell
- Re: calculation accuracy
- From: Rodrigo López Negrete
- Re: calculation accuracy
- From: John Harper
- Re: calculation accuracy
- From: Lane Straatman
- Re: calculation accuracy
- From: glen herrmannsfeldt
- Re: calculation accuracy
- Prev by Date: Re: How to inspect an array value in gdb?
- Next by Date: Re: Profiling Fortran 77 using gprof on linux
- Previous by thread: Fortran
- Next by thread: Re: calculation accuracy
- Index(es):
Relevant Pages
|