Multidimensional Newton Method

Here we show the complete output of the example worked out today in class.

The file L17.m contains all MATLAB instructions:

diary L17.txt
% We apply Newton's method on the system
%    exp(x) - y = 0,
%    x*y - exp(x) = 0,
% starting at (0.9,2.5).
x0 = 0.9; y0 = 2.5;  % start point
a = [exp(x0)  -1; y0 - exp(x0)  x0]
b = -[exp(x0) - y0; x0*y0 - exp(x0)]
dxy = a\b
x1 = x0 + dxy(1)
y1 = y0 + dxy(2)
% we cannot resist taking another step
a = [exp(x1)  -1; y1 - exp(x1)  x1]
b = -[exp(x1) - y1; x1*y1 - exp(x1)]
dxy = a\b
x2 = x1 + dxy(1)
y2 = y1 + dxy(2)
% and we continue :
a = [exp(x2)  -1; y2 - exp(x2)  x2]
b = -[exp(x2) - y2; x2*y2 - exp(x2)]
dxy = a\b
x3 = x2 + dxy(1)
y3 = y2 + dxy(2)
% the exact solution is (1,exp(1)):
error0 = [x0 - 1; y0 - exp(1)];
norm(error0)
error1 = [x1 - 1; y1 - exp(1)];
norm(error1)
error2 = [x2 - 1; y2 - exp(1)];
norm(error2)
error3 = [x3 - 1; y3 - exp(1)];
norm(error3)
diary off

The file produced by running L17.m in MATLAB is L17.txt, displayed below:

a =

    2.4596   -1.0000
    0.0404    0.9000


b =

    0.0404
    0.2096


dxy =

    0.1091
    0.2280


x1 =

    1.0091


y1 =

    2.7280


a =

    2.7432   -1.0000
   -0.0152    1.0091


b =

   -0.0152
   -0.0097


dxy =

   -0.0091
   -0.0097


x2 =

    1.0000


y2 =

    2.7183


a =

    2.7184   -1.0000
   -0.0001    1.0000


b =

   1.0e-03 *

   -0.1129
    0.0244


dxy =

   1.0e-04 *

   -0.3255
    0.2443


x3 =

    1.0000


y3 =

    2.7183


ans =

    0.2401


ans =

    0.0133


ans =

   4.0702e-05


ans =

   2.2546e-09

Observe the quadratic convergence: the errors go from 10^(-1), 10^(-2), 10^(-5), to 10^(-9). This means that the number of correct decimal places doubles in each step.