I am trying apply the function block for Newton Raphson and am a bit lost. My script is suppose to ask the user for an initial X as i've hardcoded the equation. My output file seems to just be stating zero's instead of the proper output listing it's convergence. I'm assuming i'm calling my write statement wrong or too early? Any help is appreciated.
On a side note...is it possible to also ask the user for both the equation and init value as in other languages?
program main
implicit none
real :: x0, xn, err
write(*,*) "Please enter an initial guess X0."
read(*,*) x0
write(*,*) "x = ", xn, " error = ", err
end program main
real function f(x0)
real :: x0, xn,
do
xn = x0 - ( (x0**3 - (x0) - 1) / ( ( 3*(x0**2) )-1) )
err = 100*abs( (xn-x0)/x0 )
x0 = xn
if (err < 0.000001)exit
return
end do
end function