Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Newton\'s method for solving systems of nonlinear equations is a generalization

ID: 3184874 • Letter: N

Question

Newton's method for solving systems of nonlinear equations is a generalization of the Newton's method for scalar (single variable) equation that is to solve the system f(x, y) = 0 g(x, y) = 0, written in brief as F (X) = 0, with F-|f,g]T and-IrMT, one considers the iterative method where DF is the Jacobian matrix of F: Or Oy and Fi-lao,1/01T Is an initial guess. (A) write a code that implements Newton's method for the system x2 +17-4=0 xy-1=0, starting with the initial guess xO 3, yo -1.5 (b) Determine whether the iteration converges or not to a solution of the system. (c) Do you get the same result if you start with different initial guesses?

Explanation / Answer

matlab code

close all
clear
clc

syms x y;
f(x,y) = [x^2 + y^2 - 4;
x*y - 1];
ic = [3;-1.5];
tol = 1e-16;
res = my_newton(f,ic,tol);
x = res(1)
y = res(2)

fprintf(' With different initial guesses: x0 = 1, y0 = 0 ');
ic = [1;0];
res = my_newton(f,ic,tol);
x = res(1)
y = res(2)

function res = my_newton(func,ic,tol)
res = ic;
h = 1e-6;
while true
x_ = res;
x = x_(1); y = x_(2);
func_d = [2*x 2*y;
y x];
res = res - inv(func_d)*double(func(res(1),res(2)));
if abs(x_ - res) < tol
break;
end
end
end

output

x =
1.9319
y =
0.5176

With different initial guesses: x0 = 1, y0 = 0
x =
1.9319
y =
0.5176