Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedIf 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions