newton
Newton's method for solution of nonlinear equations.
x=newton(f, xin)
(x, it, success)=newton(f, xin, showit, itmax, tol)
Inputs
f The function of the form [y,dy]=f(x) which returns the value of the function y=g(x) for the solution of g(x)=0 as well as the derivative or the Jacobian of the function.
xin An initial estimate of the solution.
showit If true the progress of iterations is displayed.
itmax The maximum number of iterations allowed.
tol The criterion for convergence of the iterations, i.e, if the norms of the estimated solution in two successive iterates differ by less than tol the iterations are terminated.
Outputs
x The computed solution, if the iterations converge.
it The number of iterations required.
success true if the iterations converge, and false otherwise.


Example
>>function (y,dy)=func(x)
>	x1=x[1],x2=x[2],x3=x[3]
>	x1x2=x1*x2
>	x2x3=x2*x3
>	expx1x2=exp(-x1x2)
>	y=[3x1-cos(x2x3)-.5 
>	   x1^2-81(x2+.1)^2+sin(x3)+1.06
>           expx1x2+20x3+(10pi-3)/3]
>	dy=[3,x3*sin(x2x3),x2*sin(x2x3)
>            2x1   -162(x2+.1)   cos(x3)
>            -x2*expx1x2  -x1*expx1x2  20]
>end
>>x=newton($func,rand(3,1),1)
Iteration 1 x norm     0.521957 y norm    15.358967 
Iteration 2 x norm     0.523525 y norm     0.492632 
Iteration 3 x norm     0.523598 y norm     0.046902 
Iteration 4 x norm     0.523599 y norm     0.000644 
Iteration 5 x norm     0.523599 y norm     0.000000 
>>x,NL
          0.5
  3.2062e-016
      -0.5236


>>func(x)
Scaled by 10^-14
            0
      -0.5107
      -0.1776