Академический Документы
Профессиональный Документы
Культура Документы
Puntos 0 1 2 3
Solución:
APROXIMACIÓN POLINOMIAL SIMPLE E INTERPOLACIÓN
format short
syms x
clc,clear
X=[140 180 220 240];%valores en x
F=[12.800 7.500 5.000 3.800];%valores en fx
N=length(X)-1;%grado del polinomio
I=1;
while I <= N+1
B(I,1)=1;
J=2;
while J <= N+1
B(I,J)=B(I,J-1)*X(I);
J=J+1;
end
I=I+1;
end
F=F';
disp([B F])
a=B\F;%resolviendo la SEL
i=(1:N+1)';
disp('______________________________')
disp(' i Grado del Polinomio a(i) ')
disp('______________________________')
disp([i,ones(N+1,1).*N,a])
a=a';
a=fliplr(a);%invertir las filas
x1=input('Ingrese el valor que quiera interpolar x=');
x=polyval(a,x1);
fprintf('El valor de F(x) interpolado es :%1.6f\n',x)
EJECUTANDO EL PROGRAMA:
1.0e+07 *
b)
POLINOMIOS DE LAGRANGE
clc
clear
c=0;
disp('_____________________________________________')
disp(' Método Numérico Polinomios de Lagrange ')
disp(' ______________________________________________')
X=[140 180 220 240];%valores en x
F=[12.800 7.500 5.000 3.800];%valores en fx
N=length(X)-1;%grado del polinomio
syms x
FX=0;
I=1;
while I<=N+1;
L=1;
J=1;
while J<=N+1;
if I~=J
L=L*(x-X(1,J))/(X(1,I)-X(1,J));
end
J=J+1;
end
FX=FX+L*F(1,I);
I=I+1;
end
disp(' Solución: ')
disp(' El polinomio aproximado es: ')
disp(simplify(FX))
xo=input(' Ingrese el valor a interpolar x= ');
f=subs(FX,xo);
fprintf(' El valor interpolando es: %f\n',f)
EJECUTANDO EL PROGRAMA:
_____________________________________________
Método Numérico Polinomios de Lagrange
______________________________________________
Solución:
El polinomio aproximado es:
-0.132500000000000 0 0
-0.062500000000000 0.000875000000000 0
-0.060000000000000 0.000041666666667 -0.000008333333333
_______________________________
Solución:
El polinomio aproximado es:
(7*(x - 140)*(x - 180))/8000 - (53*x)/400 - (4919131752989215*(x -
140)*(x - 180)*(x - 220))/590295810358705651712 + 627/20
___________________________________________________________
Interpolación Polinomio de Newton en Diferencias Finitas
___________________________________________________________
_________________________________
Tabla de Diferencias Finitas
__________________________________
-5.300000000000001 2.800000000000001
-2.500000000000000 0
2. En una reacción química, la concentración del producto 𝐶𝐵 cambia con el tiempo como se indica en la
tabla de abajo. Calcule la concentración 𝐶𝐵 cuando 𝑡 = 0.82, usando un polinomio de Newton en
diferencias finitas.
clc,clear
disp('___________________________________________________________')
disp(' Interpolación Polinomio de Newton en Diferencias Finitas ')
disp('___________________________________________________________')
Ti=[0.10 0.40 0.60 0.80 1.00];
X=Ti;
CB=[0.30 0.55 0.80 1.10 1.15];
FX=CB;
F=FX;
disp('_________________________________')
disp(' Tabla de Diferencias Finitas ')
disp(' __________________________________');
for l=0:length(X)-2;
F=diff(F);
T(1:length(X)-(l+1),l+1)=F;
end
disp([T])
d=input(' Interpolación hacia; adelante=1 atrás=2 =');
n=4;%grado del polinomio a aproximar
xo=input('Ingrese el valor pivote x(0)=');
o=0.82;%valor a interpolar
h=X(2)-X(1);
s=(o-xo)/h;
for I=1:length(X);
if X(I)==xo;
break
end
end
if d==1;
p=FX(I)+s*T(I,1);
else
p=FX(I)+s*T(I-1,1);
end
if n~=1;
if d==1
for l=1:n-1;
s=s*(s-l);
p=p+s*T(I,1+l)/prod(1:l+1);
end
else if d==2
for l=1:n-1;
s=s*(s+l);
p=p+s*T(I-(l+1),1+l)/prod(1:l+1);
end
end
end
end
disp(' Solución ')
fprintf(' El valor interpolado es: %f\n',p)
EJECUTANDO EL PROGRAMA:
__________________________________________________________
Interpolación Polinomio de Newton en Diferencias Finitas
___________________________________________________________
_________________________________
Tabla de Diferencias Finitas
__________________________________
0.2500 -0.0000 0.0500 -0.3500
0.2500 0.0500 -0.3000 0
0.3000 -0.2500 0 0
0.0500 0 0 0
3. A principios del siglo, Lord Rayleigh resolvió el problema de la destilación binaria simple (una etapa) por
lotes, con la ecuación que ahora lleva su nombre
𝐿𝑓 𝑥𝑓
𝑑𝐿 𝑑𝑥
∫ =∫
𝐿𝑖 𝐿 𝑥𝑖 𝑦 − 𝑥
donde 𝐿 son los moles de la mezcla líquida en el hervidor, 𝑥 las fracciones mol del componente más volátil en
la mezcla líquida y 𝑦 las fracciones mol de su vapor en equilibrio. Los subíndices 𝑖 y 𝑓 se refieren al estado
inicial y final, respectivamente.
Calcule qué fracción de un lote es necesario destilar en una mezcla binaria para que 𝑥 cambie de 𝑥𝑖 =
0.7 𝑎 𝑥𝑓 = 0.4. La relación de equilibrio está dada por la ecuación
𝛼𝑥
𝑦=
1 + (𝛼 − 1)𝑥
Donde 𝛼 es la volatilidad relativa de los componentes y una función de 𝑥 según la siguiente tabla(para una
mezcla dada):
clc,clear
x=[0.7 0.65 0.6 0.55 0.5 0.45 0.4];
fx=[7.3015 6.6140 6.1873 5.9290 5.8461 5.8993 6.0992];
format long
%Metodo Trapezoidal(n=1)
n=1;
a=x(1);
b=x(7);
h=(b-a)/n;
x0=a;fx0=fx(1);
x1=b;fx1=fx(7);
I=(h/2)*(fx0+fx1);
L=exp(I)
%Metodo simpson 1/3(n=2)
n=2;
a=x(1);
b=x(7);
h=(b-a)/n;
x0=a;fx0=fx(1);
x1=x0+h;fx1=fx(4);
x2=b;fx2=fx(7);
I=(h/3)*(fx0+4*fx1+fx2);
L=exp(I)
%Metodo simpson 3/8(n=3)
n=3;
a=x(1);
b=x(7);
h=(b-a)/n;
x0=a;fx0=fx(1);
x1=x0+h;fx1=fx(3);
x2=x1+h;fx2=fx(5);
x3=b;fx3=fx(7);
I=(3*h/8)*(fx0+3*fx1+3*fx2+fx3);
L=exp(I)
%(n=4)
n=4;
a=x(1);
b=x(7);
h=(b-a)/n;
x0=a;fx0=fx(1);
x1=x0+h;fx1=6.400650;%interpolando a 0.625
x2=x1+h;fx2=fx(4);
x3=x2+h;fx3=5.872700;%interpolando a 0.475
x4=b;fx4=fx(7);
I=(2*h/45)*(7*fx0+32*fx1+12*fx2+32*fx3+7*fx4);
L=exp(I)
EJECUTANDO EL PROGRAMA:
L = 0.133974606596551
L = 0.156322358994095
L = 0.156252225072972
L = 0.155828328917848
% Metodo de trapecio compuesto
clear,clc
syms x
fx=x^2/sqrt(1-x^2);
f=inline(fx);
xs=2;
xi=-2;
n=5;
h=(xs-xi)/n;
xh1=xi;
for i=1:n-1
fs1(i)=f(xh1+h);
xh=xh1+h;
xh1=xh;
end
s1=sum(fs1);
int=(h/2)*(f(xi)+2*s1+f(xs));
fprintf('Integral Aproximado I=%3.6f \n',int)
EJECUTANDO EL PROGRAMA:
Integral Aproximado I=0.279319
x 0 2 3 4 5
𝑓 0 0.0359 0.0493 0.0596 0.0700 0.0786
DIFERENCIACIÓN NUMERICA:
clc,clear
x=[0 2 3 4 5];
f=[0.0359 0.0493 0.0596 0.0700 0.0786];
n=1;
disp('DIFERENCIACION NUMERICA')
xi=x';
fi=f';
disp('___________________________________')
disp(' T - k=f(T)')
disp('___________________________________')
disp([xi,fi])
disp('____________________________________')
x1=3; %valor que se desea derivar;
h=(xi(2,1)-xi(1,1));
disp('La derivacion numerica cuando n=2 es: ')
d=((2*x1-xi(2,1)-xi(3,1)-2*h)/2*h^2)*fi(2,1)+...
((2*xi(2,1)-4*x1+2*xi(3,1)+2*h)/2*h^2)*fi(3,1)+...
((2*x1-xi(2,1)-xi(3,1))/2*h^2)*fi(4,1);
disp(d)
EJECUTANDO EL PROGRAMA:
DIFERENCIACION NUMERICA
___________________________________
T - k=f(T)
___________________________________
0 0.0359
2.0000 0.0493
3.0000 0.0596
4.0000 0.0700
5.0000 0.0786
____________________________________
La derivacion numerica cuando n=2 es:
0.0826