- #1
Nandos
- 6
- 0
For this problem use Simpson's Rule with N=256 for numerical integration function is y=×^2
and the lower limit is 1 & 3 is the upper limit.
I=[itex]\frac{h}{3}[/itex] {fstart+fend+2Ʃfeven+4Ʃfodd}
Find the numerical integration, using FORTRAN
my solution follows like this:
Program SimpsonRule
IMPLICIT NONE
REAL :: Xmax, Xmin,h , y
INTEGER :: N
Xmax=1.0
Xmin=3.0
N256
contains
h=[itex]\frac{(Xmax-Xmin)}{N}[/itex]
oddweight=4
evenweight=2
DO i=1,256
I=[itex]\frac{h}{3}[/itex] {fstart+fend+2Ʃfeven+4Ʃfodd}
integrate y=x^2
print*,I
END DO
END Program SimpsonRule
comment
I have be told that the code must have subroutine, Do statement, function and call if statement.
my problem most start when i have to tell the computer to sum odd number and multiply by factor of 4 and sum the even number also multiply by factor of two.
the answer for the problem is 8.66667
and the lower limit is 1 & 3 is the upper limit.
I=[itex]\frac{h}{3}[/itex] {fstart+fend+2Ʃfeven+4Ʃfodd}
Find the numerical integration, using FORTRAN
my solution follows like this:
Program SimpsonRule
IMPLICIT NONE
REAL :: Xmax, Xmin,h , y
INTEGER :: N
Xmax=1.0
Xmin=3.0
N256
contains
h=[itex]\frac{(Xmax-Xmin)}{N}[/itex]
oddweight=4
evenweight=2
DO i=1,256
I=[itex]\frac{h}{3}[/itex] {fstart+fend+2Ʃfeven+4Ʃfodd}
integrate y=x^2
print*,I
END DO
END Program SimpsonRule
comment
I have be told that the code must have subroutine, Do statement, function and call if statement.
my problem most start when i have to tell the computer to sum odd number and multiply by factor of 4 and sum the even number also multiply by factor of two.
the answer for the problem is 8.66667
Last edited: