%
% Exercise 1:
%
% Solve the following nonlinear equation using the Newton method:
%
% x_1 – x_2^2 = 0
% x_1^2 + x_2^2 -2 = 0
%
% Start from the point x = (1.5, 0.5).
%
x = [1.5, 0.5]’;
iter = 0;
maxiter = 6;
fprintf(‘Starting Point: \n’);
fprintf(‘x = %32.5e, %32.5e \n’, x);
fprintf(‘\n’);
while (iter < maxiter) iter = iter+1; Jacobian_f = [ 1., -2 * x(2); 2 * x(1), 2 * x(2) ]; NewtonRHS = [x(1) - x(2) * x(2); x(1) * x(1) + x(2) * x(2) - 2.0]; %Add commands to compute the Newton direction as the solution of the %Newton equations and use it to update the vector x % fprintf('Newton Method Iteration %4d: ', iter); fprintf('x = %32.5e, %32.5e \n', x); end % while (iter < maxiter)