23.10.2014 Views

Numerical Analysis Programs Using Fortran 90 - University of ...

Numerical Analysis Programs Using Fortran 90 - University of ...

Numerical Analysis Programs Using Fortran 90 - University of ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Problem: Write a <strong>Fortran</strong> program to find the value <strong>of</strong> the integral<br />

1 dt<br />

∫<br />

using Simpson’s 3/8 rule with n = 6<br />

0 2<br />

2<br />

( t + 1) (3t<br />

+ 4)<br />

! program Simpson's 3/8 Rule<br />

dimension y(0:10)<br />

f(t)=1/((t**2+1)*(3*t**2+4))**.5<br />

a=0<br />

b=1<br />

n=6<br />

h=(b-a)/n<br />

s=0<br />

do i=1,n+1<br />

x=a+h*(i-1)<br />

y(i)=f(x)<br />

enddo<br />

do i=1,n,3<br />

s=s+(3*h/8)*(y(i)+3*y(i+1)+3*y(i+2)+y(i+3))<br />

enddo<br />

print*,'Integration by Simpsons 3/8 Rule=',s<br />

end<br />

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br />

Integration by Simpson’s 3/8 rule= 4.021832 E-01<br />

38

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!