Vous êtes sur la page 1sur 6

problema1.

wxm 1 / 6

PROBLEMA1
a)EL POLINOMIO DE LAGRANGE EXPRESADO EN BASE CANONICA Y LA
PREDICCION:

(%i3) /*Utilizamos el comando Lagrange junto con los pares ordenados*/

load(interpol)$
p:[[0,4.1404],[0.133,1.1105],[0.267,0.298],[0.4,0.0799]]$
lagrange(p);
(%o3) 5.625017600180224 ( x − 0.267 ) ( x − 0.133 ) x − 62.62511889315776
( x − 0.4 ) ( x − 0.133 ) x + 233.3731360095694 ( x − 0.4 ) ( x − 0.267 ) x −
291.487144828363 ( x − 0.4 ) ( x − 0.267 ) ( x − 0.133 )

➔ /*Utilizaremos el comando Expand para obtener el polinomio en la base canonica*/;

(%i7) expand((%o3)) ;
(%o7) − 115.1141101117711 x 3 + 108.6590154742886 x 2 −
35.19659857183206 x + 4.1404

➔ /* llamaremos l(x) al polinomio de la base canonica*/

(%i8) l(x):=-115.1141101117711*x^3+108.6590154742886*x^2-35.19659857183206*x+4.1404;
(%o8) l( x ) := ( − 115.1141101117711 ) x 3 + 108.6590154742886 x 2 +
( − 35.19659857183206 ) x + 4.1404

➔ /*Utilizaremos el comando evaluar para obtener la aproximacion de la temperatura, en el punto

(%i9) ev((%o7),x=0.36);
(%o9) 0.1810689982334672

(%i10) /* tambien podemos evaluar en l(x)*/


l(0.36);
(%o10) 0.1810689982334672

b) LA GRAFICA ESTA JUNTO CON EL CODIGO

➔ /* la funcion de la varilla, evaluada en el punto xp=0.84. la llamaremos u(x)*/

(%i11) u(x):=
(27*sin(0.84*%pi)*%e^(-%pi^2*x))/%pi;
( − Ù2 ) x
27 sin( 0.84 Ù ) %e
(%o11) u( x ) :=
Ù
problema1.wxm 2 / 6

➔ /* calculamos el error entre la solucion exacta y el polinomio anterior, en el punto de a varilla xp

(%i12) e(x):=abs(u(x)-l(x));
(%o12) e( x ) := u( x ) − l( x )

(%i13) e(x);
2
27 sin( 0.84 Ù ) %e − Ù x
(%o13) abs( + 115.1141101117711 x 3 −
Ù
108.6590154742886 x 2 + 35.19659857183206 x − 4.1404 )

➔ /* representamos la funcion error en xp */

(%i14) wxplot2d([(e(x))], [x,0,0.4]);

(%t14)

(%o14)

➔ /*(b-2) calculamos el error y evaluamos cuando tp=0.36 y xp=0.84 */

(%i15) e(x);
2
27 sin( 0.84 Ù ) %e − Ù x
(%o15) abs( + 115.1141101117711 x 3 −
Ù
108.6590154742886 x 2 + 35.19659857183206 x − 4.1404 )

(%i16) e(0.36);
2
27 %e − 0.36 Ù sin( 0.84 Ù )
(%o16) 0.1810689982334672 −
Ù

(%i17) float(%o16);
(%o17) 0.06250150879247209
problema1.wxm 3 / 6

➔ /*(b-3) calculamos la medida del error,para ello realizamos una integral definica del error desd
problema1.wxm 4 / 6

(%i19) integrate((%o15)^2, x, 0, 0.4);


rat: replaced 0.4 by 2/5 = 0.4
rat: replaced 0.4 by 2/5 = 0.4
rat: replaced 0.4 by 2/5 = 0.4
rat: replaced 0.84 by 21/25 = 0.84
rat: replaced -4.1404 by -10351/2500 = -4.1404
rat: replaced 35.19659857183206 by 53463950/1519009 = 35.19659857183203
rat: replaced -108.6590154742886 by -258525550/2379237 = -108.6590154742886
rat: replaced 115.1141101117711 by 39126250/339891 = 115.1141101117711
rat: replaced -4.1404 by -10351/2500 = -4.1404
rat: replaced -35.19659857183206 by -53463950/1519009 = -35.19659857183203
rat: replaced -108.6590154742886 by
-258525550/2379237 = -108.6590154742886
rat: replaced -115.1141101117711 by
-39126250/339891 = -115.1141101117711
rat: replaced 0.4 by
2/5 = 0.4
rat: replaced 0.4 by 2/5 = 0.4
rat: replaced 0.4 by 2/5 = 0.4
rat: replaced 0.4 by 2/5 = 0.4
rat: replaced 0.84 by 21/25 = 0.84
rat: replaced -4.1404 by -10351/2500 = -4.1404
rat: replaced 35.19659857183206 by 53463950/1519009 = 35.19659857183203
rat: replaced -108.6590154742886 by -258525550/2379237 = -108.6590154742886
rat: replaced 115.1141101117711 by 39126250/339891 = 115.1141101117711
rat: replaced 115.1141101117711 by 39126250/339891 = 115.1141101117711
rat: replaced 0.84 by 21/25 = 0.84
rat: replaced -108.6590154742886 by -258525550/2379237 = -108.6590154742886
rat: replaced 115.1141101117711 by 39126250/339891 = 115.1141101117711
rat: replaced 0.84 by 21/25 = 0.84
rat: replaced 0.84 by 21/25 = 0.84
rat: replaced 17.14291216 by 104516924/6096801 = 17.14291215999997
rat: replaced -8.2808 by -10351/1250 = -8.2808
rat: replaced 17.59829928591603 by 26731975/1519009 = 17.59829928591601
rat: replaced -36.21967182476286 by -196510409/5425516 = -36.21967182476284
rat: replaced 28.77852752794277 by 19563125/679782 = 28.77852752794278
rat: replaced 1.0 by 1/1 = 1.0
rat: replaced 412.9335170088969 by 127396184/308515 = 412.9335170088975
rat: replaced 2361.356328768338 by 748150887/316831 = 2361.356328768334
rat: replaced 1893.03690668928 by
1009077644/533047 = 1893.036906689279
rat: replaced -6216.16194603564 by
-704272500/113297 = -6216.161946035641
rat: replaced -1.479322933017268e-5 by
-84008/5678814147 = -1.479322933017269e-5
rat: replaced 2.131252185245439e-4 by
2135821/10021437232 = 2.131252185245439e-4
problema1.wxm 5 / 6

(%i20) float(%o19) ;
(%o20) 0.001238715063335061

(%i21) /* (b-4)comprobamos el error entre la temperatura exacta y el polinomio*/

/* En primer lugar evaluamos los puntos dados en el polinomio de Lagrange(que hemos llamad

l(x);
(%o21) − 115.1141101117711 x 3 + 108.6590154742886 x 2 −
35.19659857183206 x + 4.1404

(%i22) l(0);
(%o22) 4.1404

(%i23) l(0.133);
(%o23) 1.1105

(%i24) l(0.267);
(%o24) 0.298

(%i25) l(0.4);
(%o25) 0.0799000000000003

(%i26) /*En segundo lugar evaluamos los puntos dados en la funcion del error absoluto evaluada en x
e(x);
2
27 sin( 0.84 Ù ) %e − Ù x
(%o26) abs( + 115.1141101117711 x 3 −
Ù
108.6590154742886 x 2 + 35.19659857183206 x − 4.1404 )

(%i27) e(0);
27 sin( 0.84 Ù )
(%o27) 4.1404 −
Ù

(%i28) float(%o27) ;
(%o28) 3.215635761666391 10 −5

(%i29) e(0.133);
2
27 %e − 0.133 Ù sin( 0.84 Ù )
(%o29) − 1.1105
Ù

(%i30) float((%o29) );
(%o30) 0.003689516610690724
problema1.wxm 6 / 6

(%i31) e(0.267);
2
27 %e − 0.267 Ù sin( 0.84 Ù )
(%o31) 0.298 −
Ù

(%i32) float(%o31) ;
(%o32) 0.001111829111525631

(%i33) e(0.4);
2
27 %e − 0.4 Ù sin( 0.84 Ù )
(%o33) 0.0799000000000003 −
Ù

(%i34) float(%o33) ;
(%o34) 6.207926043527712 10 −6

➔ /* se comprueba que el error es muy proximo a cero :) */

Vous aimerez peut-être aussi