Вы находитесь на странице: 1из 15

APROXIMACIONES DE FUNCIONES POR POLGONOS ORTOGONALES DE

LEGENDRE Y HERMITE

Presentado por Williams Hincapie Campos

Docente Ms. Carlos Galeano

Universidad Nacional de Colombia


Maestra en ingeniera Mecnica
Aplicacin de Elementos Finitos
Bogot 2010

Los polinomios que se toma son los de legendre y se aproximaran al tercer y cuarto
trmino para posteriormente, compararlo con la aproximacin. Se adoptara la metodologa
del profesor donde toma termino a trmino la matriz, entonces:
Primer termino

][

Cdigo en xmaxima
integrate((diff((legendre_p (1, rat (x))))/del(x)*(diff((legendre_p (1, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (1, rat (x))))/del(x)*(diff((legendre_p (3, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (0, rat (x))))/del(x)*(diff((legendre_p (0, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (1, rat (x))))/del(x)*(diff((legendre_p (0, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (2, rat (x))))/del(x)*(diff((legendre_p (0, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (3, rat (x))))/del(x)*(diff((legendre_p (0, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (0, rat (x))))/del(x)*(diff((legendre_p (1, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (1, rat (x))))/del(x)*(diff((legendre_p (1, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (2, rat (x))))/del(x)*(diff((legendre_p (1, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (3, rat (x))))/del(x)*(diff((legendre_p (1, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (0, rat (x))))/del(x)*(diff((legendre_p (2, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (1, rat (x))))/del(x)*(diff((legendre_p (2, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (2, rat (x))))/del(x)*(diff((legendre_p (2, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (3, rat (x))))/del(x)*(diff((legendre_p (2, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (0, rat (x))))/del(x)*(diff((legendre_p (3, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (1, rat (x))))/del(x)*(diff((legendre_p (3, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (2, rat (x))))/del(x)*(diff((legendre_p (3, rat (x))))/del(x))),x,-1,1);
integrate((diff((legendre_p (3, rat (x))))/del(x)*(diff((legendre_p (3, rat (x))))/del(x))),x,-1,1);

Segundo termino

[
[

Cdigo en xmaxima
integrate((legendre_p (0, rat (x))*(legendre_p (0, rat (x)))),x,-1,1);
integrate((legendre_p (1, rat (x))*(legendre_p (0, rat (x)))),x,-1,1);
integrate((legendre_p (2, rat (x))*(legendre_p (0, rat (x)))),x,-1,1);
integrate((legendre_p (3, rat (x))*(legendre_p (0, rat (x)))),x,-1,1);
integrate((legendre_p (0, rat (x))*(legendre_p (1, rat (x)))),x,-1,1);
integrate((legendre_p (1, rat (x))*(legendre_p (1, rat (x)))),x,-1,1);
integrate((legendre_p (2, rat (x))*(legendre_p (1, rat (x)))),x,-1,1);
integrate((legendre_p (3, rat (x))*(legendre_p (1, rat (x)))),x,-1,1);
integrate((legendre_p (0, rat (x))*(legendre_p (2, rat (x)))),x,-1,1);
integrate((legendre_p (1, rat (x))*(legendre_p (2, rat (x)))),x,-1,1);
integrate((legendre_p (2, rat (x))*(legendre_p (2, rat (x)))),x,-1,1);
integrate((legendre_p (3, rat (x))*(legendre_p (2, rat (x)))),x,-1,1);
integrate((legendre_p (0, rat (x))*(legendre_p (3, rat (x)))),x,-1,1);
integrate((legendre_p (1, rat (x))*(legendre_p (3, rat (x)))),x,-1,1);
integrate((legendre_p (2, rat (x))*(legendre_p (3, rat (x)))),x,-1,1);
integrate((legendre_p (3, rat (x))*(legendre_p (3, rat (x)))),x,-1,1);

Tercer termino
[

[
[

Cdigo en xmaxima
f (x) := legendre_p (0, rat (x))$
f1 (x) := legendre_p (1, rat (x))$
f2 (x) := legendre_p (2, rat (x))$
f3 (x) := legendre_p (3, rat (x))$
f (-1)*f (-1);
f (-1)*f1 (-1);
f2 (-1)*f (-1);
f3 (-1)*f (-1);
f1 (-1)*f1 (-1);
f2 (-1)*f1 (-1);
f3 (-1)*f1 (-1);
f (-1)*f2 (-1);
f1 (-1)*f2 (-1);
f2 (-1)*f2 (-1);
f3 (-1)*f2 (-1);
f (-1)*f3 (-1);
f1 (-1)*f3 (-1);
f2 (-1)*f3 (-1);
f3 (-1)*f3 (-1);

Como el cuarto y el quinto son la misma matriz solo que se cambie el valor por el cual se
evala se harn en el mimo programa.
Cuarto termino

Quinto termino

[
[

cdigo xmaxima
f (x) := legendre_p (0, rat (x))$
f1 (x) := legendre_p (1, rat (x))$

]
[

f2 (x) := legendre_p (2, rat (x))$


f3 (x) := legendre_p (3, rat (x))$
g(x):= (diff((legendre_p (0, rat (x)))))$
g1(x):= (diff((legendre_p (1, rat (x)))))$
g2(x):= (diff((legendre_p (2, rat (x)))))$
g3(x):= (diff((legendre_p (3, rat (x)))))$
/* se define la funcin h reescribiendo segn las derivadas que dio las funciones g */
h(x) := 0$
h1(x):=1$
h2(x):=3*x$
h3(x):=1/2*(15*x^2-3)$
h4(x):=(140*x^3-60*x)/8$
/* se evala la matriz del cuarto termino */
f(1)*h(1);
f(1)*h1(1);
f(1)*h2(1);
f(1)*h3(1);
f1(1)*h(1);
f1(1)*h1(1);
f1(1)*h2(1);
f1(1)*h3(1);
f2(1)*h(1);
f2(1)*h1(1);
f2(1)*h2(1);
f2(1)*h3(1);
f3(1)*h(1);
f3(1)*h1(1);
f3(1)*h2(1);
f3(1)*h3(1);
/* se evala la matriz del quinto termino */
f(-1)*h(-1);
f(-1)*h1(-1);
f(-1)*h2(-1);
f(-1)*h3(-1);
f1(-1)*h(-1);
f1(-1)*h1(-1);
f1(-1)*h2(-1);
f1(-1)*h3(-1);
f2(-1)*h(-1);
f2(-1)*h1(-1);
f2(-1)*h2(-1);
f2(-1)*h3(-1);
f3(-1)*h(-1);
f3(-1)*h1(-1);
f3(-1)*h2(-1);
f3(-1)*h3(-1);

Sexto termino

[ ]

Cdigo xmaxima
integrate ((f(x)), x, -1, 1);
integrate ((f1(x)), x, -1, 1);
integrate ((f2(x)), x, -1, 1);
integrate ((f3(x)), x, -1, 1);
Ultimo termino
[ ]

Cdigo mxima
f(-1); f1(-1);f2(-1);f3(-1);

Las graficas de las aproximaciones se muestran en la siguiente pagina.

Aproximacin con n=2; plot(x,Tem,x,Tem3);

Aproximacin con n=3; plot(x,Tem,x,Tem4);

Residuo

Residuo

Aproximacin con n=4; plot(x,Tem,x,Tem5);

Residuo

Como se ve a medida que se aumento la base del polinomio la funcin aproximada es


ms parecida a la buscada que es lo que se quiere hacer para este ejemplo.
El cdigo en Matlab es:
L=0.1;
%largo aleta[m]
k=360;
%Conductividad trmica del material (Aluminio)
A=0.001;
%rea de transferencia por conduccinh=10;
%Coeficiente de
conveccin
[W/(m^2 K)]
h=9;
%Coeficiente de conveccin
[W/(m^2 K)]
p=2.002; %Permetro
Tc=235;
Tin=20;
a=(h*p/(k*A))^(1/2)
A1=[0 0 0 0; 0 2 0 2; 0 0 6 0; 0 2 0 12 ];
%Matriz 1
A2=[2 0 0 0; 0 2/3 0 0; 0 0 2/5 0; 0 0 0 2/7];
%Matriz 2
A3=[1 -1 1 -1; -1 1 -1 1 ; 1 -1 1 -1; -1 1 -1 1]; %Matriz 3
A4=[0 1 3 6 ; 0 1 3 6 ; 0 1 3 6; 0 1 3 6 ];
%Matriz 4
A5=[0 1 -3 6 ; 0 -1 3 -6 ; 0 1 -3 6; 0 -1 3 -6 ]; %Matriz 5
V1=[2; 0; 0; 0];
%vector 1
V2=[1; -1; 1;-1];
%vector 2
a1=[-2/L*[A1]-(h*p*L)/(2*k*A)*[A2]+(h*p)/(k*A)*[A3]+4/L*[A4]-2/L*[A5]];
R=[-(h*p*L*Tin)/(2*k*A)*[V1]+((h*p*Tc)/(k*A))*[V2]];
A=a1^-1;
Temp=[A]*[R];
C1=(Tc-Tin)/(Tin*exp(2*a*L)+Tin);
C2=(Tc-Tin)/(Tin*(exp(-2*a*L)+1));
x=0:0.002:L;
Tem=Tin*(C1*exp(a*x)+C2*exp(-a*x)+1);
Tem3=235.47005 -930.203*x+4571.43*x.^2;
Tem4=235.078001-916.876013*x+5145.360045*x.^2-3614*x.^3;
Tem5=235.0450325-929.0778061*x+5398.758074*x.^2-7476*x.^3+19040*x.^4;
Re=Tem3-Tem;
plot(x,Re);

CAMBIO DE BASE POR POLINOMIO DE HERMITE


Se cambio la base del polinomio por una base de Hermite, que est definida entre -3 a 3,
pero como el mapeo esta para -,1,1 se deja estos lmites para los clculos entonces para
la primera aproximacin los resultados son los siguientes

Haciendo el cambio del mapeo la funcin queda en variables de x dando las siguientes
graficas

Aproximacin con n=2; plot(x,Tem,x,Tem5);

Residuo

Aproximacin con n=3; plot(x,Tem,x,Tem5);

Utilizando por polinomios de hermit tambin se llega a una buena aproximacin pero,
comparando los residuos es ms exacta la aproximacin por los polinomios de Legendre,

Por ultimo se da el cdigo en matlab y xmaxima


clc;
clear all;
close all;
L=0.1;
%largo aleta[m]
k=360;
%Conductividad trmica del material (Aluminio)
A=0.001;
%rea de transferencia por conduccinh=10;
%Coeficiente de
conveccin
[W/(m^2 K)]
h=9;
%Coeficiente de conveccin
[W/(m^2 K)]
p=2.002; %Permetro
Tc=235;
Tin=20;
a=(h*p/(k*A))^(1/2);
A1=[0 0 0 0 0; 0 8 0 -16 0; 0 0 128/3 0 -1536/5; 0 -16 0 672/5 0; 0 0 -1536/5 0
83968/35];
%Matriz 1
A2=[2 0 -4/3 0 -8/5; 0 8/3 0 -48/5 0; -4/3 0 56/15 0 -816/35; 0 -48/5 0 1312/35
0;-8/5 0 -816/35 0 67168/315];
%Matriz 2
A3=[1 -2 2 4 -20;-2 4 -4 -8 40; 2 -4 4 8 -40;4 -8 8 16 -80;-20 4040]; %Matriz
3
A4=[0 2 8 12; 0 4 16 24; 0 -8 -32 24;0 -8 -32 -48];
%Matriz 4
A5=[0 2 -8 12; 0 -4 16 -24;0 4 -16 24;0 8 -32 48 ]; %Matriz 5
V1=[2;0;-4/3;0];
%vector 1
V2=[1;-2;2;4];
%vector 2
a1=[-2/L*[A1]-(h*p*L)/(2*k*A)*[A2]+(h*p)/(k*A)*[A3]+4/L*[A4]-2/L*[A5]];
R=[-(h*p*L*Tin)/(2*k*A)*[V1]+((h*p*Tc)/(k*A))*[V2]];
A=a1^-1;
Temp=[A]*[R];
C1=(Tc-Tin)/(Tin*exp(2*a*L)+Tin);
C2=(Tc-Tin)/(Tin*(exp(-2*a*L)+1));
x=0:0.002:L;
Tem=Tin*(C1*exp(a*x)+C2*exp(-a*x)+1) solucion analitica
Temp1 = - 5.4914 *(1 - 200.0 *(2* x - 0.1).^2 ) - 213.986* (2* x - 0.1) +
209.05; primera aproximacion

Cdigo xmaxima
f(e):= hermite (0, e);
f1(e):= hermite (1, e);
f2(e):= hermite (2, e);
f3(e):= hermite (3, e);
f4(e):=hermite (4, e);
integrate((diff(f(e))/del(e)*diff(f(e))/del(e)),e,-1,1);
integrate((diff(f1(e))/del(e)*diff(f1(e))/del(e)),e,-1,1);
integrate((diff(f1(e))/del(e)*diff(f2(e))/del(e)),e,-1,1);
integrate((diff(f1(e))/del(e)*diff(f3(e))/del(e)),e,-1,1);
integrate((diff(f1(e))/del(e)*diff(f4(e))/del(e)),e,-1,1);
integrate((diff(f2(e))/del(e)*diff(f2(e))/del(e)),e,-1,1);
integrate((diff(f2(e))/del(e)*diff(f4(e))/del(e)),e,-1,1);
integrate((diff(f3(e))/del(e)*diff(f3(e))/del(e)),e,-1,1);
integrate((diff(f3(e))/del(e)*diff(f4(e))/del(e)),e,-1,1);
integrate((diff(f4(e))/del(e)*diff(f4(e))/del(e)),e,-1,1);
integrate((f(e)*f(e)),e,-1,1);
integrate((f(e)*f1(e)),e,-1,1);
integrate((f(e)*f2(e)),e,-1,1);
integrate((f(e)*f3(e)),e,-1,1);
integrate((f(e)*f4(e)),e,-1,1);
integrate((f1(e)*f1(e)),e,-1,1);
integrate((f1(e)*f2(e)),e,-1,1);
integrate((f1(e)*f3(e)),e,-1,1);
integrate((f1(e)*f4(e)),e,-1,1);
integrate((f3(e)*f1(e)),e,-1,1);
integrate((f2(e)*f2(e)),e,-1,1);
integrate((f2(e)*f3(e)),e,-1,1);
integrate((f2(e)*f4(e)),e,-1,1);
integrate((f3(e)*f4(e)),e,-1,1);
integrate((f4(e)*f4(e)),e,-1,1);
f(-1)*f(-1);
f(-3)*f1(-3);
f(-1)*f1(-1);
f(-1)*f2(-1);
f(-1)*f(-1);
f(-1)*f3(-1);
f(-1)*f4(-1);
f1(-1)*f(-1);
f1(-1)*f2(-1);
f1(-1)*f1(-1);
f1(-1)*f3(-1);

f1(-1)*f4(-1);
f2(-1)*f(-1);
f2(-1)*f1(-1);
f2(-1)*f2(-1);
f2(-1)*f3(-1);
f2(-1)*f4(-1);
f3(-1)*f(-1);
f3(-1)*f1(-1);
f3(-1)*f2(-1);
f3(-1)*f3(-1);
f3(-1)*f4(-1);
f4(-1)*f4(-1);
f3(-1)*f(-1);
h(e):=0;
h1(e):=2;
h2(e):=8*e;
h3(e):=(16*e^2-12*(1-(2*e^2)/3));
h4(e):=12*(16*e^3/3-8*e);
f(1)*h(1);
f(1)*h1(1);
f(1)*h3(1);
f(1)*h2(1);
f(1)*h4(1);
f1(1)*h(1);
f1(1)*h1(1);
f1(1)*h2(1);
f1(1)*h3(1);
f1(1)*h4(1);
f2(1)*h(1);
f2(1)*h1(1);
f2(1)*h2(1);
f2(1)*h3(1);
f2(1)*h4(1);
f3(1)*h(1);
f3(1)*h1(1);
f3(1)*h2(1);
f3(1)*h3(1);
f3(1)*h4(1);
f4(1)*h(1);
f4(1)*h4(1);
f4(1)*h1(1);
f4(1)*h2(1);
f4(1)*h3(1);
f(-1)*h(-1);
f(-1)*h1(-1);
f(-1)*h2(-1);

f(-1)*h3(-1);
f(-1)*h4(-1);
f4(-1)*h(-1);
f4(-1)*h1(-1);
f4(-1)*h2(-1);
f4(-1)*h3(-1);
f4(-1)*h4(-1);
f1(-1)*h1(-1);
f1(-1)*h2(-1);
f1(-1)*h3(-1);
f1(-1)*h4(-1);
f2(-1)*h1(-1);
f2(-1)*h2(-1);
f2(-1)*h3(-1);
f2(-1)*h4(-1);
f3(-1)*h1(-1);
f3(-1)*h2(-1);
f3(-1)*h3(-1);
f3(-1)*h4(-1);
f4(-1)*h1(-1);
integrate((f(e)),e,-1,1);
integrate((f1(e)),e,-1,1);
integrate((f2(e)),e,-1,1);
integrate((f3(e)),e,-1,1);
integrate((f4(e)),e,-1,1);
f(-1);
f1(-1);
f2(-1);
f3(-1);
f4(-1);

Conclusiones

Como primera medida se establece que a mayor grado de aproximacin menor error
encontrado debido a que el polinomio encontrado es mas exacto a la solucin exacta,
pero lo importante es que se comprob que el mtodo de los residuos ponderados es una
buena aproximacin a la solucin exacta del ejercicio. Por otro lado al hacer el cambio de
base se miro que no solo los polinomios de Legendre sirven para dar solucin a este
ejercicio si no tambin los polinomios de Hermit , pero las soluciones encontradas tuvieron
un error mas alto que las de Legendre.

Вам также может понравиться