Question: If it helps, here is some code: function [x,k] = newtons(f,x,tol,nmax) % % function [x,k] = newtons(f,x,tol,nmax) % % This function returns in x a

If it helps, here is some code: function [x,k] = newtons(f,x,tol,nmax) %If it helps, here is some code:

function [x,k] = newtons(f,x,tol,nmax)

%

% function [x,k] = newtons(f,x,tol,nmax)

%

% This function returns in x a column vector x_k such that

% || x_k - x_{k-1} ||

% and in k the number of iterations (Jacobian evaluations) required.

% On entry, x contains an initial guess.

% If k equals nmax then no convergence has been reached.

%

% The iterates ||f(x_k)|| are recorded. This option

% can be easily turned off

%Initialize

x = x(:); % ensure x is a column vector

fprintf ('k ||f(x_k)|| ')

format long g

%Newton

for k=1:nmax

[fx,Jx] = feval(f,x);

fprintf ('%d %e ',k-1,norm(fx) )

p = -Jx \ fx;

x = x + p;

if norm(p)

fx = feval(f,x);

fprintf ('%d %e ',k,norm(fx) )

return

end

end

k = nmax;

In class, we considered a special case of nonlinear systems and in particular we de- rived Newton's method for a system consisting of two nonlinear equations. Using a simplified notation, we focused on the system 9(x,y) o where Newton's method takes the form with k - 0,1,... , and subscripts denote partial derivatives with respect to variables denoted therein (f,- f/ f,- f / u. and so on) Write a MATLAB code employing Newton's method given by Eqs. (2)-(3) in order to solve Eq. (1) with f(x,y) g(x, y) x+y-2x , x2 + y2-2x + 2y + 1. = = Consider the initial guess 0.5 and stopping criteria specified by with tol 10-10 and 11-11 stands for the norm. In MATLAB the norm is implemented by the command norm (type help norm in the command window for further details) Attach your code and provide MATLAB output showcasing the expected quadratic convergence too

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!