Numerical Analysis Programs Using Fortran 90 - University of ...
Numerical Analysis Programs Using Fortran 90 - University of ...
Numerical Analysis Programs Using Fortran 90 - University of ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Problem: Write a <strong>Fortran</strong> program to find the value <strong>of</strong> the integral<br />
π<br />
2<br />
dx<br />
∫ 2<br />
sin x + cos<br />
0<br />
dimension y(20)<br />
f(x)=1/((sin(x))**2+1./4*(cos(x))**2)<br />
pi=22./7<br />
a=0; b=pi/2; n=10<br />
h=(b-a)/n<br />
do i=1,n+1<br />
x=a+h*(i-1)<br />
y(i)=f(x)<br />
print*,y(i)<br />
enddo<br />
t=0<br />
do i=1,n<br />
t=t+h*(y(i)+y(i+1))/2<br />
enddo<br />
print*,'Integration by Trapezoidal rule =',t<br />
end<br />
1<br />
4<br />
2<br />
x<br />
using Trapezoidal rule with n = 10<br />
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br />
Integration by Trapezoidal rule = 3.142227<br />
34