octave> %Newton's method in one dimension
octave> x=-2:.01:2;
octave> plot(x,x.^3-2*x)

octave> x0=2; y0=4;
octave> x1=x0+0.1*(0-4)
x1 =  1.6000
octave> y1=x1^3-2*x1
y1 =  0.89600
octave> m1=3*x1^2-2
m1 =  5.6800
octave> x2=x1+m1\(0-y1)
x2 =  1.4423
octave> y2=x2^3-2*x2
y2 =  0.11552
octave> m2=3*x2^2-2
m2 =  4.2403
octave> x3=x2+m2\(0-y2)
x3 =  1.4150
octave> y3=x3^3-2*x3
y3 =  0.0031910

octave> %Newton-Raphson method in two dimensions
octave> yt=[5;1]
yt =

   5
   1

octave> v0=[5;14]
v0 =

    5
   14

octave> y0=shfun(v0)
y0 =

   8
   1

octave> J0=jacobian(v0)
J0 =

   3.0000   2.0000
   7.0000   3.0000

octave> v1=v0+J0\(yt-y0)
v1 =

   6.8000
   9.8000

octave> y1=shfun(v1)
y1 =

    1.7600
  -16.6400

octave> J1=jacobian(v1)
J1 =

   -0.60000    2.00000
    7.00000   11.39999

octave> v2=v1+J1\(yt-y1)
v2 =

    6.7205
   11.3962

octave> y2=shfun(v2)
y2 =

   4.9937
  -1.5477

octave> v=v0, y=y0
v =

    5
   14

y =

   8
   1

octave> J=jacobian(v), v=v+J\(yt-y), y=shfun(v)
J =

   3.0000   2.0000
   7.0000   3.0000

v =

   6.8000
   9.8000

y =

    1.7600
  -16.6400

octave> J=jacobian(v), v=v+J\(yt-y), y=shfun(v)
J =

   -0.60000    2.00000
    7.00000   11.39999

v =

    6.7205
   11.3962

y =

   4.9937
  -1.5477

octave> J=jacobian(v), v=v+J\(yt-y), y=shfun(v)
J =

  -0.44108   2.00000
   7.00000   8.20768

v =

    7.0068
   11.4624

y =

   4.91807
   0.99561

octave> J=jacobian(v), v=v+J\(yt-y), y=shfun(v)
J =

  -1.0136   2.0000
   7.0000   8.0751

v =

    6.9774
   11.4885

y =

   4.99913
   0.99932

octave> J=jacobian(v), v=v+J\(yt-y), y=shfun(v)
J =

  -0.95470   2.00000
   7.00000   8.02300

v =

    6.9771
   11.4888

y =

   5.00000
   1.00000
