tarea 1- metodos numericos ii

22
TAREA 1- METODOS NUMERICOS II Vergara Gomez Luis Alexandher Marzo 2020 A continuaci´ on se presentan las soluciones a los problemas de las secciones 10.1, 10.2, 10.3, 3.1, 3.2 del libro numerical analysis de Richard L. Burden y J. Douglas Faires 8th edici´ on . Se omiten los ejercicios de temas no vistos en clase. En la primer secci´ on se muestran los algoritmos utilizados en MATLAB, adem´ as de estos se utilizaron herramientas en Wolfram y GeoGebra. 1 LISTA DE ALGORITMOS Debido a lo cansado que es la resoluci´ on de cada problema a continuaci´ on se listan los algoritmos utilizados para la soluci´ on de estos, mas adelante en cada ejercicio solo se har´ a referencia a cada algoritmo que aparece en esta lista. 1.1 etodo de Newton MATLAB (Algoritmo 1) 1 %Metodo de Newton para varias variables 2 3 function y=newtonsistema 4 xo=[0;...;0]; %iniciamos con el vector 0 5 syms x y z 6 fname=[f1(x1 ,... ,xn); f2(x1 ,... ,xn) ,... , fn(x1 ,... ,xn) ]; 7 fprima=jacobian(fname); 8 tolerancia=1.e -10; 9 maxiter = 30; 10 iter=1; 11 f=inline(fname); 12 jf=inline(fprima); 13 error= norm(f(xo(1) ,... ,xo(n)) ,2) ; 14 fprintf ( ’ e r r o r =%12.8 f \ n’, error ); 15 while error >= tolerancia 16 fxo=f(xo(1) ,... ,xo(n)); 17 fpxo=jf (xo(1) ,... ,xo(n)); 18 x1=xo-inv (fpxo) * fxo ; 19 fx1=f(x1(1) ,... ,x1(n)); 20 error = norm((fx1),2); 21 fprintf (’ Iter %2d raiz x=(%14.9f ,... ,%14.9 f) f (x)=(%14.9f ,...,%14.9f) \ n’ ,iter ,x1(1) ,... ,x1(n) ,fx1(1) ,... , fx1(n)); 22 if iter > maxiter 23 fprintf (’ Numero maximo de iteraciones excedido \ n’): 24 return ; 1

Upload: others

Post on 16-Oct-2021

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TAREA 1- METODOS NUMERICOS II

TAREA 1- METODOS NUMERICOS II

Vergara Gomez Luis Alexandher

Marzo 2020

A continuacion se presentan las soluciones a los problemas de las secciones10.1, 10.2, 10.3, 3.1, 3.2 del libro numerical analysis de Richard L. Burden y J.Douglas Faires 8th edicion . Se omiten los ejercicios de temas no vistos en clase.

En la primer seccion se muestran los algoritmos utilizados en MATLAB,ademas de estos se utilizaron herramientas en Wolfram y GeoGebra.

1 LISTA DE ALGORITMOS

Debido a lo cansado que es la resolucion de cada problema a continuacion selistan los algoritmos utilizados para la solucion de estos, mas adelante en cadaejercicio solo se hara referencia a cada algoritmo que aparece en esta lista.

1.1 Metodo de Newton MATLAB (Algoritmo 1)

1 %Metodo de Newton para var i a s v a r i a b l e s2

3 function y=newtonsistema4 xo = [ 0 ; . . . ; 0 ] ; %inic iamos con e l vec to r 05 syms x y z6 fname=[ f1 ( x1 , . . . , xn ) ; f 2 ( x1 , . . . , xn ) , . . . , fn ( x1 , . . . , xn ) ] ;7 fpr ima=jacob ian ( fname ) ;8 t o l e r a n c i a =1.e−10;9 maxiter = 30 ;

10 i t e r =1;11 f=i n l i n e ( fname ) ;12 j f=i n l i n e ( fpr ima ) ;13 error=norm( f ( xo (1 ) , . . . , xo (n) ) , 2 ) ;14 fpr intf ( ’ e r r o r=%12.8 f \n ’ , error ) ;15 while error >= to l e r a n c i a16 fxo=f ( xo (1 ) , . . . , xo (n) ) ;17 fpxo=j f ( xo (1 ) , . . . , xo (n) ) ;18 x1=xo−inv ( fpxo ) ∗ fxo ;19 fx1=f ( x1 (1 ) , . . . , x1 (n) ) ;20 error = norm( ( fx1 ) ,2 ) ;21 fpr intf ( ’ I t e r %2d r a i z x=(%14.9 f , . . . , % 1 4 . 9 f ) f ( x )=(%14.9 f

, . . . ,% 1 4 . 9 f ) \n ’ , i t e r , x1 (1 ) , . . . , x1 (n) , fx1 (1 ) , . . . , fx1 (n) ) ;22 i f i t e r > maxiter23 fpr intf ( ’ Numero maximo de i t e r a c i o n e s excedido \n ’ ) :24 return ;

1

Page 2: TAREA 1- METODOS NUMERICOS II

25 end26 xo=x1 ;27 i t e r=i t e r +1;28 end

1.2 Metodo de Broyden MATLAB (Algoritmo 2)

1

2function [ x , i t h i s t ] = broyden ( f , x0 , opt , bounds )3

4 o p t f i e l d s = { ’ maxiter ’ , ’ t o l f un ’ , ’ t o l x ’ } ;5 d e f a u l t s = {50 ,1 e−10 ,1e −8 , [ ]} ;6 i f nargin < 37 opt = [ ] ;8 end9 for i = 1 :3

10 i f i s f i e l d ( opt , o p t f i e l d s { i })11 i f isempty ( opt . ( o p t f i e l d s { i }) )12 opt . ( o p t f i e l d s { i }) = d e f a u l t s { i } ;13 end14 else15 opt . ( o p t f i e l d s { i }) = d e f a u l t s { i } ;16 end17 end18

19 x = x0 ( : ) ;20 i t = 0 ;21 F = feval ( f , x ) ;22 i f ˜( s ize (x , 1 ) == s ize (F , 1 ) )23 error ( ’ f must re turn a column vecto r o f the same s i z e as x0

’ )24 end25 normf = norm(F) ;26 J = ja c ob i ( f ,F , x ) ; % In t i a l Jacobian matrix27

28 i f nargout > 129 i t h i s t . x = [ x ( : ) ’ ; zeros ( opt . maxiter , length ( x ) ) ] ;30 i t h i s t . f = [F ( : ) ’ ; zeros ( opt . maxiter , length ( x ) ) ] ;31 i t h i s t . normf = [ normf ; zeros ( opt . maxiter , 1 ) ] ;32 end33

34 normdx = 2∗ opt . t o l x ;35 while ( i t < opt . maxiter+1 && normdx > opt . t o l x && normf > opt .

t o l f un )36 i f rcond ( J ) < 1e−1537 error ( ’ S ingu la r jacob ian at i t e r a t i o n %d\n ’ , i t )38 end39 dx = −J\F;40 normdx = norm( dx ) ;41 i f nargin > 3 % va r i a b l e bounds are supp l i e d42 % make sure x s t ay s wi th in bounds43 for j = 1 :2044 j l = find ( x+dx<bounds ( : , 1 ) ) ;45 dx ( j l ) = dx ( j l ) /2 ;46 ju = find ( x+dx>bounds ( : , 2 ) ) ;

2

Page 3: TAREA 1- METODOS NUMERICOS II

47 dx ( ju ) = dx ( ju ) /2 ;48 i f isempty ( j l ) && isempty ( ju )49 break50 end51 end52 end53 x = x+dx ;54 i t = i t +1;55 F = feval ( f , x ) ;56 normf = norm(F) ;57 J = J + F∗dx ’ / ( dx ’∗ dx ) ;58 i f nargout > 159 i t h i s t . x ( i t +1 , : ) = x ( : ) ’ ;60 i t h i s t . f ( i t +1 , : ) = F ( : ) ’ ;61 i t h i s t . normf ( i t +1 , : ) = normf ;62 end63 end64 % Check i f the i t e r a t i o n s converged and i s su e warning i f needed65 i f i t >= opt . maxiter && norm(F) > opt . t o l f un66 warning ( ’No convergence in %d i t e r a t i o n s .\n ’ , i t +1)67 e l s e i f normf>opt . t o l f un68 warning ( ’Newton step < %g , but func t i on norm > %g\n ’ , . . .69 opt . to lx , opt . t o l f un )70 e l s e i f normdx>opt . t o l x71 warning ( ’ Function norm < %g , but newton step norm > %g\n ’

, . . .72 opt . to l fun , opt . t o l x )73 end74 i f nargout > 175 i t h i s t . x ( i t +2:end , : ) = [ ] ;76 i t h i s t . f ( i t +2:end , : ) = [ ] ;77 i t h i s t . normf ( i t +2:end) = [ ] ;78 end79end80function J = ja c ob i ( f , y0 , x )81% Quick and d i r t y numerical Jacobian fo r func t i on f at x82% y0 : f ( x ) ;83 de l t a = 1e−6∗(max(1 , sqrt (norm( x ) ) ) ) ;84 n = length ( y0 ) ;85 m = length ( x ) ;86 J = zeros (n ,m) ;87 for i = 1 :m88 dx = zeros (m, 1 ) ;89 dx ( i ) = de l t a /2 ;90 J ( : , i ) = ( feval ( f , x+dx )−feval ( f , x−dx ) ) / de l t a ;91 end92end

3

Page 4: TAREA 1- METODOS NUMERICOS II

1.2.1 Interpolacion de Lagrange MATLAB (Algoritmo 3)

1

2% Lagrange In t e rpo l a c i on MATLAB3

4function [P,R, S ] = lagrangepo ly (X,Y,XX)5X = [ x 1 , . . . , x n ] ; % coordenadas x ( s in comas )6Y = [ y 1 , . . . , y n ] ; % coordenadas y ( s in comas )7

8

9

10i f s ize (X, 1 ) > 1 ; X = X’ ; end11i f s ize (Y, 1 ) > 1 ; Y = Y’ ; end12i f s ize (X, 1 ) > 1 | | s ize (Y, 1 ) > 1 | | s ize (X, 2 ) ˜= s ize (Y, 2 )13 error ( ’ both inputs must be equal−l ength ve c t o r s ’ )14end15N = length (X) ;16pva l s = zeros (N,N) ;17

18

19for i = 1 :N20

21 pp = poly (X( ( 1 :N) ˜= i ) ) ;22 pva l s ( i , : ) = pp . / polyval (pp , X( i ) ) ;23end24P = Y∗ pva l s ;25i f nargin==326 YY = polyval (P,XX) ; % output i s YY with g iven XX27 P = YY;28end29

30

31i f nargout > 132 R = roots ( ( (N−1) :−1:1) .∗ P( 1 : (N−1) ) ) ;33 i f nargout > 234

35 S = polyval (P,R) ;36 end37end

4

Page 5: TAREA 1- METODOS NUMERICOS II

1.3 Diferencias divididas de Newton MATLAB (Algoritmo4)

1

2% ingreso de datos .3

4x=[−1 0 1 2 3 ] ; y=[3 0 −1 1 2 ] ;5

6xa=x ; ya=y ;7d=zeros ( length ( y ) ) ;8d ( : , 1 )=y ’ ;9for k=2: length ( x )

10for j =1: length ( x )+1−k11

12d( j , k )=(d( j +1,k−1)−d( j , k−1) ) /(x ( j+k−1)−x ( j ) ) ;13end14end15

16for w=1: length ( x )17ds=num2str(abs (d (1 ,w) ) ) ;18i f w>119i f x (w−1)<020sg1=’+’ ;21else22sg1=’− ’ ;23end24end25

26i f d (1 ,w)<027sg2=’− ’ ;28else29sg2=’+’ ;30end31i f w==132

33acum=num2str(d (1 , 1 ) ) ;34

35%se crea un contador de nombre acum que i r almacenando e lpol inomio obtenido , y l o m o s t r a r e l f i n a l d e l codigo

36e l s e i f w==237po l i n a c t =[ ’ ( x ’ sg1 num2str(abs ( x (w−1) ) ) ’ ) ’ ] ;38

39ac tua l =[ds ’ ∗ ’ p o l i n a c t ] ;40

41acum=[acum sg2 ac tua l ] ;42else43

44po l i n a c t =[ po l i n a c t ’ .∗ ’ ’ ( x ’ sg1 num2str(abs ( x (w−1) ) ) ’ ) ’ ] ;45

46ac tua l =[ds ’ ∗ ’ p o l i n a c t ] ;47acum=[acum sg2 ac tua l ] ;48end49end50

51fprintf ( ’ l o s v a l o r e s de X e Y son ’ ) ;52disp ( xa ) ;53disp ( ya ) ;

5

Page 6: TAREA 1- METODOS NUMERICOS II

54

55fprintf ( ’ El pol inomio i n t e r p o l a c i n Newton obtenido es : %s ’ ,acum);

2 SECCION 10.1

5.- El sistema no lineal ’

x21 − 10x1 + x22 + 8 = 0x1x

22 + x1 − 10x2 + 8 = 0

transformandolo a un problema de punto fijo se tiene

x1 = g1(x1, x2) =x21+x

22+8

10

x2 = g2(x1, x2) =x1x

22+x1+810

a) Use el teorema 10.6 oara probar que G = (g1, g2)t mapeando D ⊂ R2 enR2 tiene un unico punto fijo en D = {(x1, x2)t | 0 ≤ x1, x2 ≤ 1.5}

Demostracion:

Por propiedaddes de continuidad tenemos 810 ≤

x21x

22+810 ≤ 1.2875, entonces

G(x) ∈ D siempre que x ∈ D. Luego ∂g1∂x1

= 2x1

10 ⇒ |∂g1(x)∂g1| ≤ 3

10 ; ∂g1∂x2

= 2x2

10 ⇒

|∂g2(x)∂x2| ≤ 3

10 ; ∂g2∂x1

=x22+110 ⇒ |

∂g2(x)∂x1| ≤ 3.25

10 ; ∂g2∂x2

= 2x1x2

10 ⇒ |∂g2(x)∂x2| ≤ 4.5

10

Ademas |∂gi(x)∂xj| ≤ 0.9

2 , para i, j = 2

b) Aplique iteraciones para aproximar la solucion

Considere (x(0)) = ( 12 ,

12 )t, sustituyendo tenemos

( 12 )

2+( 12 )

2+8

10 = 78 ,

( 12 )(

12 )

2+ 12+8

10 = 6980 ⇒ x(1) = ( 7

8 ,6980 )t

Sustituyendo una vez mas tenemos

( 78 )

2+( 6980 )

2+8

10 = 0.950953,( 78 )(

6980 )

2+ 78+8

10 = 0.952591⇒ x(2) = (0.950953, 0.952591)t

Hacemos una ultima iteracion

(0.950953)2+(0.952591)2+810 = 0.981174, (0.950953)(0.952591)2+0.950953+8

10 = 0.981387

Obtenemos x(3) = (0.981174, 0.981387)t

c) Utilice Gauss Seidel

6

Page 7: TAREA 1- METODOS NUMERICOS II

Vamos a tomar x(3) = (0.981174, 0.981387)t (obtenido en el inciso anterior)y tenemos

(0.981174)2+(0.981387)2+810 = 0.992582, (0.992582)(0.981387)2+(0.992582)+8

10 = 0.994855

Luego x(4) = (0.992582, 0.994855)t

Haciendo una iteracion mas obtenemos

(0.992582)2+(0.994855)2+810 = 0.997495, (0.997495)(0.994855)2+(0.997495)+8

10 = 0.998474

Y ası nos quedamos con x(5) = (0.997495, 0.998474)t

7.-

a)

G(x1, x2, x3) = ( cos(x1x3)+1/23 , 1

25

√x21 + 0.3125− 0.03,− 1

20e−x1x2 − 10π−3

60 )t

Consideramos x(0) = (1, 1, 1)t, ası sustituyendo obtenemos x(1) = (0.34676, 0.01582,−0.49149)t.Procediendo con las iteraciones tenemos:x(2) = (0.49998,−0.00368,−0.52332)t

x(3) = (0.49999,−5.333x10−7,−0.523691)t

b)

G(x1, x2, x3) = (13−x2

2+4x3

15 ,11+x3−x2

1

10 ,22+x3

2

25 )

Consideramos x(0) = (1, 1, 1)t y procediendo con las iteraciones tenemosx(1) = (0.5333, 1.1, 0.92)t

x(2) = (1.0313, 1.1635, 0.93324)t

x(3) = (1.02528, 0.90031, 0.93414)t

x(4) = (1.06173, 1.08829, 0.912422)t

x(5) = (1.031020, 1.07851, 0.93155)t

c)

G(x1, x2, x3) =(1− cos(x1x2x3), 1− (1− x1)1/4 − 0.05x23 + 0.15x3, x

21 + 0.1x22 − 0.01x2 + 1)t

Consideramos x(0) = (0, 0, 0.5)t y procediendo a iterar obtenemosx(1) = (0, 0.0625, 1)t

x(2) = (0, 0.1, 0.999)t

x(3) = (0, 0.99949, 1.0009)t

x(4) = (0, 0.10004, 0.99994)t

x(5) = (0, 0.099996, 1.00000)t

7

Page 8: TAREA 1- METODOS NUMERICOS II

d)

RESUELTO EN CLASE ,

3 SECCION 10.2

1.- Use el Metodo de Newton con x(0) = (0, 0) para computar x(2) para lossiguientes sistemas de ecuaciones no lineales.

N.B. Utilizaremos el Algoritmo 1 revisado anteriormente

a)

4x21 − 20x1 + 14x

22 + 8 = 0

12x1x

22 + 2x1 − 5x2 + 8 = 0

Computando obtenemos x(2) = (0.4958936, 1.983423)t

b)

sen(4πx1x2)− 2x2 − x1 = 0( 4π−1

4π )(e2x1 − e) + 4e22 − 2ex1 = 0

Computando obtenemos x(2) = (−0.5131616,−0.01837622)t

c)

x1(1− x1) + 4x2 − 12 = 0(x1 − 2)2 + (2x2 − 3)2 − 25 = 0

Computando obtenemos x(2) = (−23.942626, 7.6086797)t

d)

5x21 − x22 = 0x2 − 0.25(sen(x1) + cos(x2)) = 0

En este caso tenemos

J(x) =

(10x1 −2x2

−0.25 · cos(x1) 0.25 · sen(x2) + 1

)

J(x(0)) =

(0 01 1

)luego J(x(0)) es singular

8

Page 9: TAREA 1- METODOS NUMERICOS II

3.- Use un graficador para aproximar la solucion a los siguientes sistemas deecuaciones no lineales.

a)

4x21 − 20x1 + 14x

22 + 8 = 0

12x1x

22 + 2x1 − 5x2 + 8 = 0

Figure 1: Soluciones: ( 12 , 2)t, (1.09672, 6.04093)t

c)x1(1− x1) + 4x2 − 12 = 0(x1 − 2)2 + (2x2 − 3)2 − 25 = 0

Figure 2: Soluciones: (−1, 3.5)t, (2.54695, 3.985)t

9

Page 10: TAREA 1- METODOS NUMERICOS II

d)

5x21 − x22 = 0x2 − 0.25(sen(x1) + cos(x2)) = 0

Figure 3: Solucion: (0.11, 0.27)t

10

Page 11: TAREA 1- METODOS NUMERICOS II

5.-Use las graficas y respuestas anteriores para aproximar con el metodo deNewton hasta ||x(k) − x(k−1)||∞ < 10−6

Usaremos las respuestas obtenidas en el inciso anterior:

a)

Considere x(0) = ( 12 , 2)t y obtenemos

x(1) =

(1/22

)−(−1/15 −1/60−1/15 −4/15

)·(

00

)=

(1/22

)Luego ||x(k) − x(k−1)|| = 0 < 10−6

c)

Considere x(0) = (−1, 3.5)t y obtenemos

x(1) =

(−13.5

)−(−3 −11 1/4

)·(

00

)=

(−13.5

)Luego ||x(k) − x(k−1)|| = 0 < 10−6

d)

Considere x(0) = (0.11, 0.27)t y obtenemos

x(1) =

(0.110.27

)−(

1.02644 0.5196680.239048 1.05858

)·(−0.01240.001612

)=

(0.121890.271258

)Luego ||x(k) − x(k−1)|| = 0.01189

7.- Use el metodo de Newton para encontrar la solucion de los siguientessistemas de ecuaciones no lineales.

Usando el algoritmo 1 tenemos:

a)

Use x(0) = (1, 1)t

3x21 − x22 = 03x1x

22 − x31 − 1 = 0

11

Page 12: TAREA 1- METODOS NUMERICOS II

obtenemos x(5) = (0.5000000, 0.8660254)t

b)

Use x(0) = (2, 2)t

ln(x2+x22)−sen(x1x2)=ln2+lnπ

ex1−x2 + cos(x1x2) = 0

Iterando obtenemos x(6) = (1.772454, 1.772454)t

c)

Use x(0) = (−1,−2, 1)t

x31 + x21x2 − x1x3 + 6 = 0ex1 + ex2 − x3 = 0x22 − 2x1x3 = 4

Iterando obtenemos x(5) = (−1.456043,−1.664230, 0.4224934)t

d)

Use x(0) = (0, 0, 0)t

6x1 − 2 · cos(x1x2)− 1 = 09x2 +

√x21 + sen(x3 + 1.06) + 0.9 = 0

60x3 + 3e−x1x2 + 10π − 3 = 0

Iterando obtenemos x(4) = (0.4981447,−0.1996059,−0.5288260)t

9.- El sistema no lineal

3x1 − cos(x2x3)− 12 = 0

x21 − 625x22 − 14 = 0

e−x1x2 + 20x3 + 10π−33 = 0

tiene una matriz jacobiana singular en la solucion. Aplique el metodo deNewton con x(0) = (1, 1,−1)t. Note que la convergencia puede ser lenta o noocurrir dentro de un numero razonable de iteraciones.

Solucion:

Si consideramos tolerancia=10−6 usando el algoritmo 1 obtenemosx(20) = (0.5, 9.5× 10−7,−0.5235988)t

12

Page 13: TAREA 1- METODOS NUMERICOS II

11.- Demuestre que para n = 1, el metodo de Newton dado por la ecuacion(10.9) se reduce al metodo dado por la ecuacion (2.5)

Demostracion:

Si la dimension de n es 1 tenemos que F (x) es una funcion de un componentef(x) = f1(x), y el vector x tambien es de un componente x1 = x. Luego elJacobiano J(x) se reduce a una matriz 1×1 de la forma [∂f1/∂x1(x)] = f ′(x) =f ′(x) y ası

x(k) = x(k−1) − J(x(k−1))−1F(x(k−1))

y se convierte en la ecuacion escalar

xk = xk−1 − f(xk−1)−1f(xk−1) = xk−1 − f(xk−1)f ′(xk−1)

4 SECCION 10.3

Usaremos el algoritmo numero 2

1.- Use el metodo de Broyden con x(0) = 0 para computar x(2) en cada unode los siguientes sistemas de ecuaciones:

a)

4x21 − 20x1 + 14x

22 + 8 = 0

12x1x

22 + 2x1 − 5x2 + 8 = 0

Solucion:

Tenemos x(2) = (0.4777920, 1.927557)t

b)

sen(4πx1x2)− 2x2 − x1 = 0( 4π−1

4π )(e2x1 − e) + 4ex22 − 2ex1 = 0

Solucion:

Tenemos x(2) = (−0.3250070, 0.1386967)t

c)

3x21 − x22 = 03x1x

22 − x31 − 1 = 0

13

Page 14: TAREA 1- METODOS NUMERICOS II

Solucion:

Tenemos x(2) = (0.5229372, 0.8243491)t

d)

ln(x21 + x22)− sen(x1x2 = ln2 + lnπ)ex1−x2 + cos(x1x2) = 0

Solucion:

Tenemos x(2) = (1.779500, 1.743396)t

3.- Use el metodo de Broyden para aproximar las soluciones de los sistemasde ecuaciones no lineales del ejercicio anterior usando las x(0) dadas. Itere hastaque ||x(k) − x(k−1)||∞ < 10−6

Solucion:

a) Use x(0) = (0, 0)t

Obtenemos x(8) = (0.5, 2)t

b) Use x(0) = (0, 0)t

Obtenemos x(9) = (−0.3736982, 0.05626649)t

c) Use x(0) = (1, 1)t

Obtenemos x(9) = (0.5, 0.8660254)t

d) Use x(0) = (2, 2)t

Obtenemos x(8) = (1.772454, 1.772454)t

5.- Use el metodo de Broyden para aproximar la solucion de los siguientessistemas de ecuaciones no lineales. Itere hasta que ||x(k) − x(k−1)||∞ < 10−6

a)

x1(1− x1) + 4x2 = 12(x1 − 2)2 + (2x2 − 3)2 = 25

Solucion:

Usando x(0) = (2.5, 4)t obtenemos x(3) = (2.546947, 3.984998)

14

Page 15: TAREA 1- METODOS NUMERICOS II

b)

5x21 − x22 = 0x2 − 0.25(sen(x1) + cos(x2)) = 0

Solucion:

Usando x(0) = (0.11, 0.27)t obtenemos x(4) = (0.1212419, 0.2711052)t

c)

15x1 + x22 − 4x3 = 13x21 + 10x2 − x3 = 11x32 − 25x3 = −22

Solucion:

Usando x(0) = (1, 1, 1)t obtenemos x(3) = (1.036401, 1.085707, 0.9311914)t

d)

10x1 − 2x22 + x2 − 2x3 − 5 = 08x22 + 4x23 − 9 = 0

8x2x3 + 4 = 0

Solucion:

Usando x(0) = (1,−1, 1)t obtenemos x(8) = (0.9,−1, 0.5)t

7.-El siguiente sistema no lineal tiene una matriz jacobiana singular. Apliqueel metodo de Broyden con x(0) = (1, 1,−1)t. La convergencia puede ser lenta yen un numero de iteraciones

Solucion:

Tomando x(0) = (1, 1,−1)t tenemos x(56) = (0.5000591, 0.01057235,−0.5224818)t

9.- Pruebe que si u,v ∈ Rn entonces det(I + uvt) = 1 + vtu

Demostracion:

Sea λ el eigenvalor de M = (I + uvt) con x 6= 0 un eigenvector. Entonces

λx = Mx = (I + uvt)x = x + (vtx)u

15

Page 16: TAREA 1- METODOS NUMERICOS II

Ası, (λ − 1)x = (vtx)u. Si λ = 1 entonces vtx = 0. Entonces λ = 1 es uneigenvalor de M con multiplicidad n− 1 y los eigenvectores x(0), ...,x(n) dondevtx(j) = 0 para j = 1, ..., n− 1. Suponiendo que λ 6= 1 implicarıa que x y u sonparalelas. Supongamos ahora que x = αu, luego (λ− 1)αu = (vt(αu))u.Luego,α(λ− 1)u = α(vtu)uimplica que λ− 1 = vtu o bien λ = 1 + vtu. Entonces Mtiene los eigenvalores λi, i ≤ i ≤ n donde λi = 1 para i = 1, ..., n − 1 y λn =1 + vtu. Por lo que el determinante M =

∏ni=1 λi, y tenemos det M = 1 + vtu.

5 SECCION 3.1

1.-Para las siguientes funciones f(x), sea x0 = 0, x1 = 0.6 y x2 = 0.9. Construyalos polinomios de interpolacion para aproximar f(0.45)

a) f(x) = cos(x)b) f(x) =

√1 + x

c)f(x) = ln(x+ 1)d)f(x) = tan(x)

a)

P1(x) = −0.148878x+ 1; P1(0.45) = 0.933005|f(0.45)− P1(0.45)| = 0.032558P2(x) = −0.452592x2 − 0.0131009x+ 1; P2(0.45) = 0.902455|f(0.45)− P2(0.45)| = 0.002008

b)

P1(x) = 0.467251x+ 1; P1(0.45) = 1.210263|f(0.45)− P1(0.45)| = 0.0061104P2(x) = −0.7800x2; P2(0.45) = 1.204998|f(0.45)− P2(0.45)| = 0.000839

c)

P1(x) = 0.874548x; P1(0.45) = 0.393546|f(0.45)− P1(0.45)| = 0.0212983P2(x) = −0.268961x2 + 0.846593x; P2(0.45) = 0.375392|f(0.45)− P2(0.45)| = 0.003828

d)

P1(x) = 1.031121x; P1(0.45) = 0.464004|f(0.45)− P1(0.45)| = 0.019051P2(x) = 0.615092x2 + 0.8446593x; P2(0.45) = 0.505523

16

Page 17: TAREA 1- METODOS NUMERICOS II

|f(0.45)− P2(0.45)| = 0.022468

3.-Use el teorema 3.3 para encontrar el error en el ejercicio anterior

a

Para P1(x) : | f′′(ξ)2 (0.45− 0)(0.45− 0.6)| ≤ 0.135

Para P2(x) : | f′′′(ξ)6 (0.45− 0)(0.45− 0.6)(0.45− 0.9)| ≤ 0.00397

b)

Para P1(x) : | f′′(ξ)2 (0.45− 0)(0.45− 0.6)| ≤ 0.03375

Para P2(x) : | f′′′(ξ)6 (0.45− 0)(0.45− 0.6)(0.45− 0.9)| ≤ 0.001898

c)

Para P1(x) : | f′′(ξ)2 (0.45− 0)(0.45− 0.6)| ≤ 0.135

Para P2(x) : | f′′′(ξ)6 (0.45− 0)(0.45− 0.6)(0.45− 0.9)| ≤ 0.010125

d)

Para P1(x) : | f′′(ξ)2 (0.45− 0)(0.45− 0.6)| ≤ 0.06779

Para P2(x) : | f′′′(ξ)6 (0.45− 0)(0.45− 0.6)(0.45− 0.9)| ≤ 0.151

5.-Use interpolacion de Lagrange de grado 1,2 y 3 para aproximar lo sigu-iente:

a) f(8.4) si f(8.1) = 16.94410, f(8.3) = 17.56492, f(8.6) = 18.50515,f(8.7) = 18.82091

b) f(− 13 ) si f(−0.75) = −0.07181250, f(−0.5) = −0.02475000, f(−0.25) =

0.33493750, f(0) = 1.10100000c) f(0.25) si f(0.1) = 0.62049958, f(0.2) = −0.28398668, f(0.3) = 0.00660095,

f(0.4) = 0.24842440d) f(0.9) si f(0.6) = −0.17694460, f(0.7) = 0.01375227, f(0.8) = 0.22363362,

f(1.0) = 0.65809197Solucion:

Colocaremos los resultados en el siguiente orden

n; x0, ..., xn; Pn(valor asignado)

a)

1; 8.3, 8.6; Pn(8.4) = 17.878332; 8.3, 8.6, 8.7; Pn(8.4) = 17.87716

3; 8.3, 8.6, 8.7, 8.1; Pn(8.4) = 17.87714

17

Page 18: TAREA 1- METODOS NUMERICOS II

b)

1; −0.5,−0.25; Pn(−1/3) = 0.215041672; −0.5,−0.25, 0.0; Pn(−1/3) = 0.16988889

3; −0.5,−0.25, 0.0,−0.75; Pn(−1/3) = 0.17451852

c)

1; 0.2, 0.3; Pn(0.25) = −0.138692872; 0.2, 0.3, 0.4; Pn(0.25) = −0.13259734

3; 0.2, 0.3, 0.4, 0.1; Pn(0.25) = −0.13277477

d)

1; 0.8, 1.0; Pn(0.9) = −0.440862802; 0.8, 1.0, 0.7; Pn(0.9) = −0.43841352

3; 0.8, 1.0, 0.7, 0.6; Pn(0.9) = −0.44198500

9.-Los datos del ejercicio anterior fueron obtenidos usando las siguientes fun-ciones. Use la formula del error y compare con el error actual para los casosn = 1 y n = 2

a)

P2(x) = −11.22388889x2 + 2.810500000x+ 1, y el error es 0.11371294

b)

P2(x) = −0.1306344167x2+0.8969979335x−0.63249693 y el error es 9.45762×10−4

c)

P3(x) = 0.1970056667x3 − 1.06259055x2 + 2.532453189x− 1.666868305 y elerror es 10−4

d)

P3(x) = −0.07932x3 − 0.545506x2 + 1.0065992x+ 1 y el error es 1.591376×10−3

13.- Sea P3(x) la interpolacion polinomial de los datos (0, 0), (0.5, y), (1, 3)y (2, 2). Halle y si el coeficiente de x3 en P3(x) es 6

Solucion:

Haciendo interpolacion y despejando obtenemos y = 1.25

18

Page 19: TAREA 1- METODOS NUMERICOS II

15.-Utilice los siguientes valores y redondee a 4 dıgitos para construir la ter-cera aproximacion polinomica de Lagrange para f(0.9). La funcion que ha sidoaproximada es f(x) = log10(tan(x)). Halle los errores correspondientes

Solucion

Computando tenemos f(1.09) ∼ 0.2826. El error ”actual” es 4.3 × 10−5, yel otro error es 7.4× 10−6

19.- Construya los polinomios de Lagrange para las siguientes funciones yencuentre un limite para el error absoluto en el intervalo [x0, xn]

Solucion:

Computando obtenemos

a) P2(x) = −11.22388889x2 + 3.810500000x+ 1Y el error es 0.11371294

b) P2(x) = −0.1306344167x2 + 0.8969979335x− 0.63249693Y el error es 9.45762× 10−4

c) P3(x) = 0.1970056667x3 − 1.06259055x2 + 2.532453189x− 1.666868305Y el error es 10−4

d) P3(x) = −0.07932x3 − 0.545506x2 + 1.0065992x+ 1Y el error es 1.591376× 10−3

23.- Suponga que xj = j para j = 0, 1, 2, 3 y sabemos que

P0,1(x) = 2x+ 1, P0,2(x) = x+ 1 y P1,2,3(2.5) = 3

Halle P0,1,2,3(2.5)

Solucion:

Computando obtenemos P0,1,2,3(2.5) = 2.875

6 Seccion 3.2

Para la solucion de los siguientes problemas haremos uso del algoritmo 4

1.- Use la ecuacion (3.10) o el algoritmo 3.2 para construir los polinomios deinterpolacion de grado 1, 2 y 3 para los siguientes datos

19

Page 20: TAREA 1- METODOS NUMERICOS II

a) f(8.4) si f(8.1) = 16.94410, f(8.3) = 17.56492, f(8.6) = 18.50515, f(8.7) =18.82091

b) f(0.9) si f(0.6) = −0.17694460, f(0.7) = 0.01375227, f(0.8) = 0.22363362, f(1.0) =0.65809197

Solucion:

a)P1(x) = 16.9441 + 3.1041(x− 81); P1(8.4) = 17.87533P2(x) = P1(x) + 0.06(x− 8.1)(x− 8.3); P2(8.4) = 17.87713P3(x) = P2(x)− 0.00208333(x− 8.1)(x− 8.3)(x− 8.6); P3(8.4) = 17.87714

b)P1(x) = −0.1769446 + 1.9069687(x− 0.6); P1(0.9) = 0.395146P2(x) = P1(x) + 0.959224(x− 0.6)(x− 0.7); P2(0.9) = 0.4526995P3(x) = P2(x) + 1.785741(x− 0.6)(x− 0.7)(x− 0.8); P3(0.9) = 0.4419850

3.-Use diferencias divididas de Newton para construir los polinomios de in-terpolacion de grado 1, 2 y 3 para los siguientes datos

a) f(−1/3) si f(−0.75) = −0.07181250, f(−0.5) = −0.0247500, f(−0.25) =0.33493750, f(0) = 1.10100000

b) f(0.25) si f(0.1) = −0.62049958, f(0.2) = −0.28398668, f(0.3) = 0.00660095, f(0.4) =0.24842440

Solucion:

Considere s = ( 1h )(x− x0)

a)P1(s) = −0.718125− 0.0470625s; P1(−1/3) = −0.006625P2(s) = P1(s) + 0.312625s(s− 1)/2; P2(−1/3) = 0.1803056P3(s) = P2(s) + 0.09375s(s− 1)(s− 2)/6; P3(−1/3) = 0.1745185

b)P1(s) = −0.62049958 + 0.3365129s; P1(0.25) = −0.1157302P2(s) = P1(s)− 0.04592527s(s− 1)/2; P2(0.25) = −0.1329522P3(s) = P2(s)− 0.00283891s(s− 1)(s− 2)/6; P3(0.25) = −0.1327748

5.–Use diferencias divididas de Newton para construir los polinomios de in-terpolacion de grado 1, 2 y 3 para los siguientes datos

a) f(−1/3) si f(−0.75) = −0.07181250, f(−0.5) = −0.02475000, f(−0.25) =0.33493750, f(0) = 1.10100000

20

Page 21: TAREA 1- METODOS NUMERICOS II

b) f(0.25) si f(0.1) = −0.62049958, f(0.2) = −0.28398668, f(0.3) = 0.00660095, f(0.4) =0.24842440

a)Solucion:

Considere s = (1/h)(x− xn)

a)P1(s) = 1.101 + 0.7660625s; f(− 1

3 ) ≈ P1(− 43 ) = 0.07958333

P2(s) = P1(s) + 0.406375s(s+ 1)/2; f(−1/3) ≈ P2(−4/3) = 0.1698889P3(s) = P2(s) + 0.09375s(s+ 1)(s+ 2)/6; P3(−4/3) = 0.1745185

b)P1(s) = 0.2484244 + 0.2418235s; f(0.25) ≈ P1(−1.5) = −0.1143108P2(s) = P1(s)− 0.04876419s(s+ 1)/2; f(0.25) ≈ P2(−1.5) = −0.1325973P3(s) = P2(s)−0.00283891s(s+1)(s+2)/6; f(0.25) ≈ P3(−1.5) = −0.1327748

7.-a)Use el algoritmo 3.2 para construir el el polinomio de interpolacion degrado 3 de los siguientes datos

x = −0.1, 0.0, 0.2, 0.3f(x) = 5.30000, 2.00000, 3.19000, 1.00000

b) Agregue f(0.35) = 0.97260 y construya el polinomio de grado 4

Solucion:

a) P3(x) = 5.3− 33(x+ 0.1) + 129.83(x+ 0.1)x− 556.6(x+ 0.1)x(x− 0.2)

b) P4(x) = P3(x) + 2730.243387(x+ 0.1)x(x− 0.2)(x− 0.3)

9.-a) Aproxime f(0.05) usando los siguientes datos usando diferencias divi-didas de Newton

x = 0.0, 0.2, 0.4, 0.6, 0.8f(x) = 1.00000, 1.22140, 1.49182, 1.82212, 2.22554

b)Aproxime f(0.65)

Solucion:

a) f(0.05) ≈ 1.05126b) f(0.65) ≈ 1.91555

11.-a) Pruebe que los polinomios

21

Page 22: TAREA 1- METODOS NUMERICOS II

P (x) = 3− 2(x+ 1) + 0(x+ 1)(x) + (x+ 1(x)(x− 1))Q(x) = −1 + 4(x+ 2)− 3(x+ 2)(x+ 1) + (x+ 2)(x+ 1)(x)

interpolan los datosx = −2,−1, 0, 1, 2f(x) = −1, 3, 1,−1, 3

b) ¿Por que la parte a) no viola la propiedad de unicidad de los polinomiosde interpolacion?

Solucion:

a)Es facil ver queP (−2) = Q(−2) = −1, P (−1) = Q(−1) = 3, P (0) = Q(0) = 1, P (1) =

Q(1) = −1, P (2) = Q(2) = 3

b) Basta notar que si P (x) y Q(x) se expanden entonces son los mismos

13.-Considere los datos

x = 0, 1, 2P (x) = 2,−1, 4

Determine el coeficiente de x2 en P (x) si todas las diferencias en adelante deorden cuatro son 1

Solucion:

Computando y despejando obtenemos que el coeficiente de x2 es 3.5

22