Thank you for your response. I have a second query:
If i want to modify NR1 above to NR2(f,x0,N,eps) where eps is a real number so that it returns the first iterate xk for which |x[k]-x[k-1]|<eps and k<=N. However, if |x[k]-x[k-1]|>=eps for k=1,...,N, then an error message should be displayed.
If the procedure is correct then for f:= x-> x^5-1 i should get an answer when x0=0.60+0.20i and the error message when x0=0.60+0.16i.
The code i've written so far is incorrect but i'm not sure where i'm going wrong. Would you be able to give me some pointers?
> local x,k:
> x := x0:
> for k to N do:
> if abs(x[k]-x[k-1]) >= eps then
> print("Convergence has not been achieved!"):
> return :
> end if:
> x := x-f(x)/D(f)(x)
> end do:
> end proc:f:= x-> x^5-1:
Error, (in NR2) cannot determine if this expression is true or false: .1e-4 <= abs((.6+.16*I)-(.6+.16*I))
Error, (in NR2) cannot determine if this expression is true or false: .1e-4 < abs((.6+.20*I)-(.6+.20*I))
Thanks in advance.