Curso de Métodos Numéricos. Sistemas de ecuaciones no...

Preview:

Citation preview

Curso de M etodos Num ericos.Sistemas de ecuaciones no lineales

Curso : Metodos Numericos en Ingenierıa

Profesor : Dr. Jose A. Otero Hernandez

Universidad : ITESM CEM

Fecha : Jueves, 24 de septiembre de 2014

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

TOPICOS

1 INTRODUCCIONSistema de ecuaciones no lineales

2 METODO DE ITERACION DE PUNTO FIJOPresentacion del metodoPrograma MATLABCondicion de convergencia

3 METODO DE NEWTON-RAPHSONPresentacion del metodoPrograma MATLAB

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Topicos

1 INTRODUCCIONSistema de ecuaciones no lineales

2 METODO DE ITERACION DE PUNTO FIJOPresentacion del metodoPrograma MATLABCondicion de convergencia

3 METODO DE NEWTON-RAPHSONPresentacion del metodoPrograma MATLAB

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Sistema de ecuaciones no lineales

¿Que es un sistema de ecuaciones no lineales?

f1(x1, x2, ..., xn) = 0,f2(x1, x2, ..., xn) = 0,

...fn(x1, x2, ..., xn) = 0.

¿Que es un sistema de ecuaciones no lineales?

xi, i = 1, 2, . . . , n→ Incognitas

fi, i = 1, 2, . . . , n→ Funciones no lineales con respecto xi

Ejemplos

u(x, y) = x2 + x y − 10 = 0v(x, y) = y + 3x y2 − 57 = 0

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Sistema de ecuaciones no lineales

Soluci onSi xs = [xs

1, xs2, ..., x

sn], es la solucion del sistema de

ecuaciones

Entonces: fi(xs) = 0, para i = 1, 2, . . . , n

Soluci on exactaLos sistemas de ecuaciones no lineales no tienen solucionexacta o analıtica.

Soluciones numericas son necesarias

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Topicos

1 INTRODUCCIONSistema de ecuaciones no lineales

2 METODO DE ITERACION DE PUNTO FIJOPresentacion del metodoPrograma MATLABCondicion de convergencia

3 METODO DE NEWTON-RAPHSONPresentacion del metodoPrograma MATLAB

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Presentaci on del m etodo

Metodos de iteraci on de punto fijo

El metodo de iteracion de punto fijo estudiado anteriormentepuede modificarse para resolver un sistema de ecuaciones nolineales simultaneas.

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Presentaci on del m etodo

Ejemplos I

Busquemos la solucion del sistema de ecuaciones no lineales:

u(x, y) = x2 + x y − 10 = 0v(x, y) = y + 3x y2 − 57 = 0

Hallar la funcion gx(x, y):

gx (x, y) =10− x2

y

Hallar la funcion gy(x, y):

gy (x, y) = 57− 3xy2

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Presentaci on del m etodo

Algoritmo

xi+1 = gx (xi, yi)yi+1 = gy (xi+1, yi)

Algoritmo: Ejemplos I

xi+1 = 10−x2i

yi

yi+1 = 57− 3xi+1y2i

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

funct ion puntof i joSENv1 (Gx, Gy, x0 , y0 ,EE)% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %% puntof i joSENv1 : Nombre de l a func ion% Valores de entrada% Gx : func ion de entrada−>x=gx ( x , y )% Gy : func ion de entrada−>y=gy ( x , y )% x0 : Valor de i n i c i a l de x% y0 : Valor de i n i c i a l de y% EE : Er ro r Estimado% Valores de s a l i d a% Sal ida : Raiz x , EA x , Raiz y , EA y% IM : I t e r a c i o n Maxima% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %gx= i n l i n e (Gx, ’ x ’ , ’ y ’ ) ; gy= i n l i n e (Gy, ’ x ’ , ’ y ’ ) ;IM = 1 ; x ( IM ) =x0 ; y ( IM ) =y0 ;x ( IM+1)=gx ( x ( IM ) , y ( IM ) ) ; y ( IM+1)=gy ( x ( IM+1) , y ( IM ) ) ;EAx( IM+1)=abs ( ( x ( IM+1)−x ( IM ) ) / x ( IM+1) ) ∗100;EAy( IM+1)=abs ( ( y ( IM+1)−y ( IM ) ) / y ( IM+1) ) ∗100;while EAx( IM+1)>EE && EAy( IM+1)>EE

IM=IM+1;x ( IM+1)=gx ( x ( IM ) , y ( IM ) ) ; y ( IM+1)=gy ( x ( IM+1) , y ( IM ) ) ;EAx( IM+1)=abs ( ( x ( IM+1)−x ( IM ) ) / x ( IM+1) ) ∗100;EAy( IM+1)=abs ( ( y ( IM+1)−y ( IM ) ) / y ( IM+1) ) ∗100;

endSal1 =[ ’ I t e r a c i o n Maxima= ’ ,num2str ( IM ) ] ;Sal2 =[ x ( 2 : size ( x , 2 ) ) ’ EAx ( 2 : size ( x , 2 ) ) ’ y ( 2 : size ( y , 2 ) ) ’ EAy ( 2 : size ( y , 2 ) ) ’ ] ;disp ( ’ ’ )disp ( Sal1 )disp ( ’ ’ )disp ( ’ Raiz x EApro x Raiz y EApro y ’ )disp ( Sal2 )

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

>> puntof i joSENv1 ( ’ (10−x ˆ 2 ) / y ’ , ’57−3∗x∗y ˆ2 ’ , 1 .5 ,3 .5 ,0 .001 )

I t e r a c i o n Maxima=106

Raiz x EApro x Raiz y EApro y

1.0e+154 ∗

0.0000 0.0000 −0.0000 0.0000−0.0000 0.0000 0.0000 0.0000

0.0000 0.0000 −0.0000 0.0000−0.0000 0.0000 0.0000 0.0000

0.0000 0.0000 −0.0000 0.0000−0.0000 0.0000 0.0000 0.0000

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 .0000 0.0000 −0.0066 0.0000−0.0000 0.0000 0.1976 0.0000

0.0000 0.0000 −5.9275 0.0000−0.0000 0.0000 I n f NaN

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

Ejemplos II

Busquemos la solucion del sistema de ecuaciones no lineales:

u(x, y) = x2 + x y − 10 = 0v(x, y) = y + 3x y2 − 57 = 0

Hallar la funcion gx(x, y):

gx (x, y) =√

10− xy

Hallar la funcion gy(x, y):

gy (x, y) =

√57− y

3x

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

Algoritmo

xi+1 =√

10− xiyi

yi+1 =√

57−yi

3xi+1

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

>> puntof i joSENv1 ( ’ (10−x∗y ) ˆ0 .5 ’ , ’ ((57−y ) / (3∗ x ) ) ˆ0 .5 ’ , 1 .5 ,3 .5 ,0 .001 )

I t e r a c i o n Maxima=11

Raiz x EApro x Raiz y EApro y2.1794 31.1753 2.8605 22.35601.9405 12.3118 3.0496 6.19912.0205 3.9557 2.9834 2.21711.9930 1.3762 3.0057 0.74192.0024 0.4673 2.9981 0.25521.9992 0.1601 3.0007 0.08702.0003 0.0547 2.9998 0.02981.9999 0.0187 3.0001 0.01022.0000 0.0064 3.0000 0.00352.0000 0.0022 3.0000 0.00122.0000 0.0007 3.0000 0.0004

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Condici on de convergencia

Convergencia

∣∣∣∣∂gx

∂x

∣∣∣∣ +∣∣∣∣∂gx

∂y

∣∣∣∣ < 1∣∣∣∣∂gy

∂x

∣∣∣∣ +∣∣∣∣∂gy

∂y

∣∣∣∣ < 1

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Topicos

1 INTRODUCCIONSistema de ecuaciones no lineales

2 METODO DE ITERACION DE PUNTO FIJOPresentacion del metodoPrograma MATLABCondicion de convergencia

3 METODO DE NEWTON-RAPHSONPresentacion del metodoPrograma MATLAB

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Presentaci on del m etodo

Metodos de Newton-Raphson

El metodo de Newton-Raphson estudiado anteriormente puedemodificarse para resolver un sistema de ecuaciones no linealessimultaneas.

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Presentaci on del m etodo

Serie de Taylor de multiples variables

ui+1 = ui + (xi+1 − xi)∂ui

∂x+ (yi+1 − yi)

∂ui

∂y

vi+1 = vi + (xi+1 − xi)∂vi

∂x+ (yi+1 − yi)

∂vi

∂y

Considerando ui+1 = vi+1 = 0, para las raıces aproximadas,llegamos a un sistema de ecuaciones para determinar xi+1 yyi+1:

Serie de Taylor de multiples variables

xi+1∂ui

∂x+ yi+1

∂ui

∂y= −ui + xi

∂ui

∂x+ yi

∂ui

∂y

xi+1∂vi

∂x+ yi+1

∂vi

∂y= −vi + xi

∂vi

∂x+ yi

∂vi

∂y

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Presentaci on del m etodo

Formula de Newton-Raphson

xi+1 = xi −ui

∂vi∂y − vi

∂ui∂y

∂ui∂x

∂vi∂y −

∂ui∂y

∂vi∂x

yi+1 = yi −vi

∂ui∂x − ui

∂vi∂x

∂ui∂x

∂vi∂y −

∂ui∂y

∂vi∂x

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

funct ion newtonraphsonSENv1 (U, V, x0 , y0 ,EE)% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %% newtonraphsonSENv1 : Nombre de l a func ion% Valores de entrada% U, V : func iones U y V% x0 : Valor de i n i c i a l de x , y0 : Valor de i n i c i a l de y0 , EE : Er ro r Estimado% Valores de s a l i d a% Sal ida : IM : I t e r a c i o n Maxima , Raiz y Er ro r Aproximado% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %u= i n l i n e (U, ’ x ’ , ’ y ’ ) ; v= i n l i n e (V, ’ x ’ , ’ y ’ ) ; syms x yd i f f u x = d i f f (U, x ) ; d i f f u y = d i f f (U, y ) ; d i f f v x = d i f f (V, x ) ; d i f f v y = d i f f (V, y ) ;dux= i n l i n e ( d i f f u x , ’ x ’ , ’ y ’ ) ; duy= i n l i n e ( d i f f u y , ’ x ’ , ’ y ’ ) ; dvx= i n l i n e ( d i f f v x , ’ x ’ , ’ y ’ ) ;dvy= i n l i n e ( d i f f v y , ’ x ’ , ’ y ’ ) ; IM = 1 ; rx ( IM ) =x0 ; ry ( IM ) =y0 ;rx ( IM+1)= rx ( IM )−(u ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) )−v ( rx ( IM ) , ry ( IM ) ) ∗ . . .

duy ( rx ( IM ) , ry ( IM ) ) ) / ( dux ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) ) − . . .duy ( rx ( IM ) , ry ( IM ) )∗dvx ( rx ( IM ) , ry ( IM ) ) ) ;

ry ( IM+1)= ry ( IM )−(v ( rx ( IM ) , ry ( IM ) )∗dux ( rx ( IM ) , ry ( IM ) )−u ( rx ( IM ) , ry ( IM ) ) ∗ . . .dvx ( rx ( IM ) , ry ( IM ) ) ) / ( dux ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) ) − . . .duy ( rx ( IM ) , ry ( IM ) )∗dvx ( rx ( IM ) , ry ( IM ) ) ) ;

EAx( IM+1)=abs ( ( rx ( IM+1)−rx ( IM ) ) / rx ( IM+1) ) ∗100;EAy( IM+1)=abs ( ( ry ( IM+1)−ry ( IM ) ) / ry ( IM+1) ) ∗100;while ( EAx( IM+1)>EE) && (EAy( IM+1)>EE)

IM=IM+1;rx ( IM+1)= rx ( IM )−(u ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) )−v ( rx ( IM ) , ry ( IM ) ) . . .

∗duy ( rx ( IM ) , ry ( IM ) ) ) / ( dux ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) ) − . . .duy ( rx ( IM ) , ry ( IM ) )∗dvx ( rx ( IM ) , ry ( IM ) ) ) ;

ry ( IM+1)= ry ( IM )−(v ( rx ( IM ) , ry ( IM ) )∗dux ( rx ( IM ) , ry ( IM ) )−u ( rx ( IM ) , ry ( IM ) ) . . .∗dvx ( rx ( IM ) , ry ( IM ) ) ) / ( dux ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) ) − . . .duy ( rx ( IM ) , ry ( IM ) )∗dvx ( rx ( IM ) , ry ( IM ) ) ) ;

EAx( IM+1)=abs ( ( rx ( IM+1)−rx ( IM ) ) / rx ( IM+1) ) ∗100;EAy( IM+1)=abs ( ( ry ( IM+1)−ry ( IM ) ) / ry ( IM+1) ) ∗100;

end

Sal ida1 =[ ’ I t e r a c i o n Maxima= ’ ,num2str ( IM ) ] ;Sal ida2 =[ rx ( 2 : size ( rx , 2 ) ) ’ EAx ( 2 : size ( rx , 2 ) ) ’ r y ( 2 : size ( ry , 2 ) ) ’ . . .

EAy ( 2 : size ( ry , 2 ) ) ’ ] ;disp ( ’ ’ )disp ( Sal ida1 )disp ( ’ ’ )disp ( ’ Raiz x EApro x Raiz y EApro y ’ )disp ( Sal ida2 )

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

Sal ida1 =[ ’ I t e r a c i o n Maxima= ’ ,num2str ( IM ) ] ;Sal ida2 =[ rx ( 2 : size ( rx , 2 ) ) ’ EAx ( 2 : size ( rx , 2 ) ) ’ r y ( 2 : size ( ry , 2 ) ) ’ . . .

EAy ( 2 : size ( ry , 2 ) ) ’ ] ;disp ( ’ ’ )disp ( Sal ida1 )disp ( ’ ’ )disp ( ’ Raiz x EApro x Raiz y EApro y ’ )disp ( Sal ida2 )

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

>> newtonraphsonSENv1 ( ’ x ˆ2+x∗y−10 ’ , ’ y+3∗x∗yˆ2−57 ’ , 1 .5 ,3 .5 ,0 .001 )

I t e r a c i o n Maxima=4

Raiz x EApro x Raiz y EApro y2.0360 26.3272 2.8439 23.07151.9987 1.8676 3.0023 5.27642.0000 0.0650 3.0000 0.07632.0000 0.0000 3.0000 0.0000

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

funct ion newtonraphsonSENv2 (U, Ux , Uy , V, Vx , Vy , x0 , y0 ,EE)% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %% newtonraphsonSENv2 : Nombre de l a func ion% Valores de entrada% U, Ux , Uy : func iones U, dU / dx , dU / dy% V , Vx , Vy : func iones V , dV / dx , dV / dy% x0 : Valor de i n i c i a l de x , y0 : Valor de i n i c i a l de y0 , EE : Er ro r Estimado% Valores de s a l i d a% Sal ida : IM : I t e r a c i o n Maxima , Raiz y Er ro r Aproximado% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %u= i n l i n e (U, ’ x ’ , ’ y ’ ) ; dux= i n l i n e (Ux , ’ x ’ , ’ y ’ ) ; duy= i n l i n e (Uy , ’ x ’ , ’ y ’ ) ;v= i n l i n e (V, ’ x ’ , ’ y ’ ) ; dvx= i n l i n e ( Vx , ’ x ’ , ’ y ’ ) ; dvy= i n l i n e ( Vy , ’ x ’ , ’ y ’ ) ;IM = 1 ; rx ( IM ) =x0 ; ry ( IM ) =y0 ;rx ( IM+1)= rx ( IM )−(u ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) )−v ( rx ( IM ) , ry ( IM ) ) ∗ . . .

duy ( rx ( IM ) , ry ( IM ) ) ) / ( dux ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) ) − . . .duy ( rx ( IM ) , ry ( IM ) )∗dvx ( rx ( IM ) , ry ( IM ) ) ) ;

ry ( IM+1)= ry ( IM )−(v ( rx ( IM ) , ry ( IM ) )∗dux ( rx ( IM ) , ry ( IM ) )−u ( rx ( IM ) , ry ( IM ) ) ∗ . . .dvx ( rx ( IM ) , ry ( IM ) ) ) / ( dux ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) ) − . . .duy ( rx ( IM ) , ry ( IM ) )∗dvx ( rx ( IM ) , ry ( IM ) ) ) ;

EAx( IM+1)=abs ( ( rx ( IM+1)−rx ( IM ) ) / rx ( IM+1) ) ∗100;EAy( IM+1)=abs ( ( ry ( IM+1)−ry ( IM ) ) / ry ( IM+1) ) ∗100;while ( EAx( IM+1)>EE) && (EAy( IM+1)>EE)

IM=IM+1;rx ( IM+1)= rx ( IM )−(u ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) )−v ( rx ( IM ) , ry ( IM ) ) . . .

∗duy ( rx ( IM ) , ry ( IM ) ) ) / ( dux ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) ) − . . .duy ( rx ( IM ) , ry ( IM ) )∗dvx ( rx ( IM ) , ry ( IM ) ) ) ;

ry ( IM+1)= ry ( IM )−(v ( rx ( IM ) , ry ( IM ) )∗dux ( rx ( IM ) , ry ( IM ) )−u ( rx ( IM ) , ry ( IM ) ) . . .∗dvx ( rx ( IM ) , ry ( IM ) ) ) / ( dux ( rx ( IM ) , ry ( IM ) )∗dvy ( rx ( IM ) , ry ( IM ) ) − . . .duy ( rx ( IM ) , ry ( IM ) )∗dvx ( rx ( IM ) , ry ( IM ) ) ) ;

EAx( IM+1)=abs ( ( rx ( IM+1)−rx ( IM ) ) / rx ( IM+1) ) ∗100;EAy( IM+1)=abs ( ( ry ( IM+1)−ry ( IM ) ) / ry ( IM+1) ) ∗100;

end

Sal ida1 =[ ’ I t e r a c i o n Maxima= ’ ,num2str ( IM ) ] ;Sal ida2 =[ rx ( 2 : size ( rx , 2 ) ) ’ EAx ( 2 : size ( rx , 2 ) ) ’ r y ( 2 : size ( ry , 2 ) ) ’ . . .

EAy ( 2 : size ( ry , 2 ) ) ’ ] ;disp ( ’ ’ )disp ( Sal ida1 )disp ( ’ ’ )disp ( ’ Raiz x EApro x Raiz y EApro y ’ )disp ( Sal ida2 )

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

Sal ida1 =[ ’ I t e r a c i o n Maxima= ’ ,num2str ( IM ) ] ;Sal ida2 =[ rx ( 2 : size ( rx , 2 ) ) ’ EAx ( 2 : size ( rx , 2 ) ) ’ r y ( 2 : size ( ry , 2 ) ) ’ . . .

EAy ( 2 : size ( ry , 2 ) ) ’ ] ;disp ( ’ ’ )disp ( Sal ida1 )disp ( ’ ’ )disp ( ’ Raiz x EApro x Raiz y EApro y ’ )disp ( Sal ida2 )

INTRODUCCION METODO DE ITERACION DE PUNTO FIJO METODO DE NEWTON-RAPHSON

Programa MATLAB

>>U = ’ x ˆ2+x∗y−10 ’ ; Ux = ’2∗x+y ’ ; Uy = ’ x ’ ;>>V = ’ y+3∗x∗yˆ2−57 ’ ; Vx = ’3∗y ˆ2 ’ ; Vy = ’ 1+6∗x∗y ’ ;

>> newtonraphsonSENv2 (U, Ux , Uy , V, Vx , Vy , 1 . 5 , 3 . 5 , 0 . 0 0 1 )

I t e r a c i o n Maxima=4

Raiz x EApro x Raiz y EApro y2.0360 26.3272 2.8439 23.07151.9987 1.8676 3.0023 5.27642.0000 0.0650 3.0000 0.07632.0000 0.0000 3.0000 0.0000

Recommended