Question: The simple Fortran program below by default finds the root of the following function: f(x) = exp(x) x = 0. Modify the Newton-Raphson program to
The simple Fortran program below by default finds the root of the following function:
f(x) = exp(x) x = 0. Modify the Newton-Raphson program to solve the following system of equations:
exp(x) sin(x) + (x) = 6
(x) + exp(x) sin(x) = 1
Submit the print out of the source code and output.
c...... Newton-Raphson program..........................
implicit none
integer*4 i, nit
real*8 fl,fr,f,fp,x,dx,eps
x = 0
eps = 0.00000001
nit= 10
i=0
100 CONTINUE
i = i+1
call ffunction (fl,x-eps)
call ffunction (fr,x+eps)
f = 0.5*(fr+fl)
fp= (fr-fl)/(2*eps)
dx = -f/fp
x = x+dx
if(abs(dx).gt.eps) GOTO 100
write (6,*) STOPPED
write(6,*)Numer of iterations: , i, and x = , x
END
c...... subroutine to assign value of f for given x.....
subroutine ffunction(f,x)
implicit none
real*8 pi
parameter (pi = 3.141592653589793)
real*8 f, x
c...... you can define your function f(x) ..............
f = EXP(x)-x*x
RETURN
END
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
