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 program to find the roots <strong>of</strong> the equation<br />

x<br />

y = e − 3x<br />

using Bisection method in the interval [ 1,2]<br />

, within<br />

3<br />

the tolerance 10 − .<br />

f(x)=exp(x)-3*x<br />

tol=.001<br />

a=1<br />

b=2<br />

10 c=(a+b)/2<br />

print*,a,b,c<br />

if (f(c)*f(a))20,30,30<br />

20 b=c<br />

goto 40<br />

30 a=c<br />

40 if (abs (a-b).lt.tol) goto 50<br />

goto 10<br />

50 print*,'The Root is',c<br />

end<br />

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

1.000000 2.000000 1.500000<br />

1.500000 2.000000 1.750000<br />

1.500000 1.750000 1.625000<br />

1.500000 1.625000 1.562500<br />

1.500000 1.562500 1.531250<br />

1.500000 1.531250 1.515625<br />

1.500000 1.515625 1.507813<br />

1.507813 1.515625 1.511719<br />

1.511719 1.515625 1.513672<br />

1.511719 1.513672 1.512695<br />

The Root is 1.512695<br />

2

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

Saved successfully!

Ooh no, something went wrong!