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 determine the roots <strong>of</strong> the equation<br />

4<br />

3<br />

2<br />

x −1.99x<br />

−1.76x<br />

+ 5.22x<br />

− 2.23 = 0 that are close to x = 1. 5<br />

by Newton-Raphson method.<br />

f(x)=x**4-1.99*x**3-1.76*x**2+5.22*x-2.23<br />

df(x)=4*x**3-5.97*x**2-3.52*x+5.22<br />

ddf(x)=12*x**2-11.94*x-3.52<br />

tol=0.00001<br />

xo=1.5<br />

10 x=xo-df(xo)/ddf(xo)<br />

if(abs(x-xo).lt.tol) goto 20<br />

xo=x<br />

goto 10<br />

20 eps=sqrt(-2*f(x)/ddf(x))<br />

y1=x+eps<br />

30 y=y1-f(y1)/df(y1)<br />

if(abs(y-y1).lt.tol) goto 40<br />

print *,y<br />

y1=y<br />

goto 30<br />

40 print *,'The First Root is',y<br />

print*,'************************'<br />

y1=x-eps<br />

50 y=y1-f(y1)/df(y1)<br />

if(abs(y-y1).lt.tol) goto 60<br />

print *,y<br />

y1=y<br />

goto 50<br />

60 print *,'The Second Root is',y<br />

end<br />

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

1.565973<br />

1.565888<br />

The First Root is 1.565888<br />

************************************<br />

1.424016<br />

1.424112<br />

The Second Root is 1.424112<br />

++++++++++++++++++++++++++<br />

8

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

Saved successfully!

Ooh no, something went wrong!