NewtonRoot_sys2

# NewtonRoot_sys2 - %substitutes trial solutions into...

This preview shows page 1. Sign up to view the full content.

%%This program finds a numerical solution to a system of 2 non-linear functions using Newtons method clear Xest = -1; %trial x solution Yest = 2; %trial y solution imax = 20; %number of iterations syms x y F1 F2; %symbolic variables F1 = sin(x)+cos(y); %symbolic Function 1 F2 = x^2 + y^2 - 5; %symbolic Function 2 dF1x = diff(F1,x); %differential of F1 with respect to x dF1y = diff(F1,y); %differential of F1 with respect to y dF2x = diff(F2,x); %differential of F2 with respect to x dF2y = diff(F2,y); %differential of F2 with respect to y Jacob = dF1x*dF2y - dF1y*dF2x; %determinant of the Jacobian for n = 1:imax Jac = subs(Jacob,{x,y},{Xest,Yest});
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %substitutes trial solutions into Jacobian %%the next two lines calculate the Taylor expanded change in x and y %using Cramers rule delX = (-subs(F1,{x,y},{Xest,Yest})*subs(dF2y,{x,y},{Xest,Yest}) + subs(F2, {x,y},{Xest,Yest})*subs(dF1y,{x,y},{Xest,Yest}))/Jac; delY = (-subs(F2,{x,y},{Xest,Yest})*subs(dF1x,{x,y},{Xest,Yest}) + subs(F1, {x,y},{Xest,Yest})*subs(dF2x,{x,y},{Xest,Yest}))/Jac; x2(n) = Xest + delX; %calculates new trial solution in x y2(n) = Yest + delY; %calculates new trial solution in y Xest = x2(n); %resets variable x Yest = y2(n); %resets variable y end Xest Yest Y...
View Full Document

## This note was uploaded on 04/01/2011 for the course ECM 006 taught by Professor Higgins during the Spring '07 term at UC Davis.

Ask a homework question - tutors are online