Redo Example 10.4.2 using Broyden’s method instead of Newton’s method.
Solution.
We have the same vector function to be equated to zero
\begin{equation*}
\mathbf F(\mathbf x) = \begin{pmatrix} x_1+x_2+x_3 +2 \\
x_1x_2 + x_1x_3 + x_2x_3 + 7 \\
x_1x_2x_3 + 1
\end{pmatrix}
\end{equation*}
but no longer use its Jacobian matrix. The code is modified by computing the steps as
h = -B*F(x) and updating the matrix B according to Broyden’s method.F = @(x) [x(1) + x(2) + x(3) + 2;
x(1)*x(2) + x(1)*x(3) + x(2)*x(3) + 7;
x(1)*x(2)*x(3) + 1];
x = [1; 2; 3];
B = eye(3);
max_tries = 10000;
for k = 1:max_tries
h = -B*F(x);
w = F(x+h) - F(x);
B = B + (h - B*w)*h'*B / (h'*B*w);
x = x + h;
if norm(h) < 100*eps(norm(x))
break
end
end
if k < max_tries
fprintf('Found a solution after %d steps:\n', k);
disp(x)
fprintf('The norm of F(x) is %g\n', norm(F(x)))
else
disp('Failed to converge')
end
Starting from the same point
[1; 2; 3] as we used for Newton’s method, we get:
Found a solution after 1359 steps:
1.7240
-3.8737
0.1497
By contrast, Newton’s method converged in 9 steps. There is a price to pay for the lack of Jacobian matrix.
