Download presentation

Presentation is loading. Please wait.

Published byStephan Rho Modified over 2 years ago

1
Lecture 14: Newton’s method for system of two nonlinear equations Function newton2d01 Set initial (x,y) point, maximum number of iterations, and convergence tolerance. for i= 1:maxiter Perform Newton update; check for convergence; print iterates end Define functions f1(x,y), and f2(x,y) and Jacobian matrix: Jacob(x,y). Download newton2d01.m

2
function newton2d01 %solution of system of two nonlienar equations % f1(x,y) = exp(x)*y = 0 % f2(x,y) = x*cos(y) = 0 % using a Newton iteration. Calls function f1 and f2 and % Jacobian matrix Jacob. % % Setup x = 0.2; y =.5; %initial point (x0,y0) maxiter = 25; %maximum number of iterations tol = 1.e-6; % tolerance (backward error goal) err = inf; iter = 0; disp(['Iteration number = ',num2str(iter),' x=',num2str(x),' y=',num2str(y)]); % Newton update. while err > tol & iter <= maxiter J = Jacob(x,y); rhs = -[f1(x,y);f2(x,y)]; dxy = J\rhs; x = x + dxy(1); y = y + dxy(2); err = norm([f1(x,y);f2(x,y)],Inf); iter = iter+1; disp(['Iteration number = ',num2str(iter),' x=',num2str(x),' y=',num2str(y), ' Backward error=',num2str(err)]); end

3
function z = f1(x,y) z = exp(x)*y; function z = f2(x,y) z = x*cos(y); function xx = Jacob(x,y) %value of Jacobian matrix xx = [exp(x)*y, exp(x); cos(y), -x*sin(y)]; Continue with function newton2d01

4
>> newton2d01 Iteration number = 0 x=0.2 y=0.5 Iteration number = 1 x=-0.04144 y=0.12072 Backward error=0.11582 Iteration number = 2 x=0.00063241 y=-0.005079 Backward error=0.0050822 Iteration number = 3 x=-1.6304e-008 y=-3.2121e-006 Backward error=3.2121e-006 Iteration number = 4 x=1.6822e-019 y=5.2369e-014 Backward error=5.2369e-014 >>

5
Inclass 1 Modify function newton2d01 to find root of the following nonlinear system: f1(x,y) = sin(y)/(x^2+1) = 0 f2(x,y) = cos(2*y)*sin(x) = 0 For initial point (x0,y0)=(0.4,0.3) and tol=10^(-14)

6
Iteration number = 0 x=0.4 y=0.3 Iteration number = 1 x=-0.28646 y=-0.15578 Backward error=0.26896 Iteration number = 2 x=0.0431 y=0.028678 Backward error=0.043016 Iteration number = 3 x=-0.0001693 y=-0.00011466 Backward error=0.0001693 Iteration number = 4 x=1.0521e-011 y=7.0755e-012 Backward error=1.0521e-011 Iteration number = 5 x=0 y=0 Backward error=0

Similar presentations

OK

ME451 Kinematics and Dynamics of Machine Systems Newton-Raphson Method October 04, 2013 Radu Serban University of Wisconsin-Madison.

ME451 Kinematics and Dynamics of Machine Systems Newton-Raphson Method October 04, 2013 Radu Serban University of Wisconsin-Madison.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on google chrome os Ppt on different types of search engines Ppt on views in oracle A ppt on presentation skills Download ppt on acid bases and salts for class 10 Ppt on air pollution act Ppt on agriculture for class 8th Ppt on electrical power generation system using railway track slides Ppt on role of water resources management Ppt on job rotation benefits