- #1
ttiger2k7
- 58
- 0
[SOLVED] Riemann Sum with Fortran 90
My assignment: Use Reimann Sums to estimate pi to 6 decimal places (ie: you can stop when successive iterations yield a change of less than 0.000001. For the Reimann Sums solution, an iteration equals 2X the number of segments as the trial before. Print out the results and number of iterations.
So, I'm trying the best way to do this. We're supposed to use a unit circle, so the equation for a circle will be 1 = (x^2+y^2)^.5
I'm not that good at Fortran, but I've started part of it. This assignment is really confusing me, I just don't know if the start I have is even going to work. If there's anyone that can point me in the right direction, that'd be great.
PROGRAM riemann
IMPLICIT NONE
REAL,PARAMETER::lower=0.0, upper=1.0
REAL::dx,x,y
integer::i
y=0.0
x=0.0
dx=(upper-lower)/i
DO i=1,i*2
y=(1-x**2)**.5
x=x+dx
?
?
END DO
END PROGRAM
My assignment: Use Reimann Sums to estimate pi to 6 decimal places (ie: you can stop when successive iterations yield a change of less than 0.000001. For the Reimann Sums solution, an iteration equals 2X the number of segments as the trial before. Print out the results and number of iterations.
So, I'm trying the best way to do this. We're supposed to use a unit circle, so the equation for a circle will be 1 = (x^2+y^2)^.5
I'm not that good at Fortran, but I've started part of it. This assignment is really confusing me, I just don't know if the start I have is even going to work. If there's anyone that can point me in the right direction, that'd be great.
PROGRAM riemann
IMPLICIT NONE
REAL,PARAMETER::lower=0.0, upper=1.0
REAL::dx,x,y
integer::i
y=0.0
x=0.0
dx=(upper-lower)/i
DO i=1,i*2
y=(1-x**2)**.5
x=x+dx
?
?
END DO
END PROGRAM