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

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

23.10.2014 Views

Problem: Write a Fortran program to find first derivation from the following data at x = 0. 1 using derivation of Lagrange polynomial. x 0.1 0.2 0.3 0.4 y 0.01 0.04 0.09 0.16 ! Derivation using Lagrange Formula dimension x(40),y(40) n=4 xx=0.1 data (x(i), i=1,4)/.1,.2,.3,.4/ data (y(i), i=1,4)/.01,.04,.09,.16/ d=0 do i=1,n s=0 do j=1,n if (j.eq.i) goto 10 p=1 do k=1,n if ((k.eq.j).or.(k.eq.i)) goto 20 p=p*(xx-x(k))/(x(i)-x(k)) 20 enddo s=s+p/(x(i)-x(j)) 10 enddo d=d+s*y(i) enddo print*,'The First Derivation=',d end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The First Derivation= 2.000000E-01 48

Problem: Write a Fortran program to find first derivation of the function 2 3 f ( x) = ln(5x ) + 8x −8 at x =1. 1 using derivation of Lagrange polynomial. ! Derivation using Lagrange Formula f(x)=log(5*x**2)+8*x**3-8 n=4 xo=1.1 h=.1 d=0 do i=1,n s=0 do j=1,n if (j.eq.i) goto 10 p=1 do k=1,n if ((k.eq.j).or.(k.eq.i)) goto 20 p=p*(1-k)/(i-k) 20 enddo s=s+p/((i-j)*h) 10 enddo d=d+s*f(xo+h*(i-1)) enddo print*,'The First Derivation=',d end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The First Derivation= 30.856790 49

Problem: Write a <strong>Fortran</strong> program to find first derivation from the<br />

following data at x = 0. 1 using derivation <strong>of</strong> Lagrange<br />

polynomial.<br />

x 0.1 0.2 0.3 0.4<br />

y 0.01 0.04 0.09 0.16<br />

! Derivation using Lagrange Formula<br />

dimension x(40),y(40)<br />

n=4<br />

xx=0.1<br />

data (x(i), i=1,4)/.1,.2,.3,.4/<br />

data (y(i), i=1,4)/.01,.04,.09,.16/<br />

d=0<br />

do i=1,n<br />

s=0<br />

do j=1,n<br />

if (j.eq.i) goto 10<br />

p=1<br />

do k=1,n<br />

if ((k.eq.j).or.(k.eq.i)) goto 20<br />

p=p*(xx-x(k))/(x(i)-x(k))<br />

20 enddo<br />

s=s+p/(x(i)-x(j))<br />

10 enddo<br />

d=d+s*y(i)<br />

enddo<br />

print*,'The First Derivation=',d<br />

end<br />

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

The First Derivation= 2.000000E-01<br />

48

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

Saved successfully!

Ooh no, something went wrong!