newton2var - disp(' PROGRAMA: NEWTON PARA DOS VARIABLES')...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 % PROGRAMA: NEWTON PARA DOS VARIABLES % Descripcion:El programa encuentra la raiz (x,y) para un sistema de ecuaciones f(x,y) y g(x,y) % con una aproximacion inicial "(xo,yo)" utilizando el metodo de Newton % para dos variables. % curso: Calculo Numerico % programacion: Rony Yupanqui G. % fecha: Agosto 2006 % VARIABLES % aproximacion inicial xo=-0.5 yo=1.5 % ingreso de funciones f=inline('(x-1)*(x-1)-(y-1)*(y-1)-2','x','y') g=inline('x*x+y*y-4','x','y') % ingreso de derivadas parciales dfx=inline('2*(x-1)','x','y') dfy=inline('-2*(y-1)','x','y') dgx=inline('2*x','x','y') dgy=inline('2*y','x','y') % tolerancia tol=0.001 % ALGORITMO DEL PROGRAMA
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: disp(' PROGRAMA: NEWTON PARA DOS VARIABLES') disp(' N X Y ERROR') error=1 xant=xo yant=yo n=1 while (error>tol) j=feval(dfx,xant,yant)*feval(dgy,xant,yant)-feval(dfy,xant,yant)*feval(dgx,xant,yant) xa=xant-(feval(f,xant,yant)*feval(dgy,xant,yant)-feval(g,xant,yant)*feval(dfy,xant,yant))/j ya=yant-(feval(g,xant,yant)*feval(dfx,xant,yant)-feval(f,xant,yant)*feval(dgx,xant,yant))/j %tipo de error error=abs(ya-yant)+abs(xa-xant) linea=sprintf(' %d %5.8f %5.8f %5.8f',n,xa,ya,error) disp(linea) xant=xa yant=ya n=n+1 end linea=sprintf('\n RAIZ UBICADA EN (X,Y) = %5.8f %5.8f ', xant,yant) disp(linea)...
View Full Document

This note was uploaded on 06/18/2008 for the course MATH Calc taught by Professor Doig during the Spring '08 term at Pontifical Catholic University of Peru.

Ask a homework question - tutors are online