Está en la página 1de 9

FACULTAD DE INGENIERIA QUÍMICA

Escuela profesional de ingeniería química

APROXIMACION E
NOVENA TAREA
INTERPOLACION

MÉTODOS NUMÉRICOS

CATEDRATICO:

Ing. EUFRACIO ARIAS, Wilder


INTEGRANTE:

VARGAS RAMOS, Zulema Amelia


SECCIÓN:
A

IV SEMESTRE
HUANCAYO -2018
PROBLEMA CON VALOR FISICO 1:
1. Con los siguientes valores.

Puntos 0 1 2 3

l/r 140 180 220 240


p/a 12,800 7,500 5,000 3,800
donde 𝑝/𝑎 es la carga en 𝑙𝑏/𝑝𝑢𝑙𝑔2 que causa la ruptura de una columna de
hierro dulce con extremos redondeados y 𝑙/𝑟 es la razón de la longitud de la
columna al mínimo radio de giro de su sección transversal. Encuentre el
polinomio de tercer grado que pasa por estos puntos en sus distintas formas
𝑙
e interpolar = 150 :
𝑟
a) 𝑃3(𝑥) = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 (aproximación polinomial simple).
b) Forma de Lagrange.
c) Aproximación de Newton (en diferencias divididas).
d) Aproximación de Newton en diferencias finitas (hacia delante y hacia
atrás).

APROXIMACION POLINOMIAL SIMPLE


function simple
clc,clear
syms x
X=[140 180 220 240];
F=[12.800 7.500 5.000 3.800];
N=length(X)-1;
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;
i=(1:N+1)';
disp(' i Grado del Polinomio a(i) ')
disp([i,ones(N+1,1).*N,a])
a=a';
a=fliplr(a);
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);
end
EJECUTANDO PROGRAMA
1.0e+07 *
0.0000 0.0000 0.0020 0.2744 0.0000
0.0000 0.0000 0.0032 0.5832 0.0000
0.0000 0.0000 0.0048 1.0648 0.0000
0.0000 0.0000 0.0058 1.3824 0.0000
i Grado del Polinomio a(i)
1.0000 3.0000 99.6000
2.0000 3.0000 -1.2092
3.0000 3.0000 0.0054
4.0000 3.0000 -0.0000
Ingrese el valor que quiera interpolar x=150
El valor de F(x) interpolado es :11.037500

POLINOMIO DE LAGRANCE
function lagrange
clc;clear
c=0;
X=[140 180 220 240];
F=[12.800 7.500 5.000 3.800];
N=length(X)-1;
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= ');
disp('el valor interpolado es:');
f=subs(FX,xo)
end

EJECUTANDO PROGRAMA:
El polinomio aproximado es:
- x^3/120000 + (43*x^2)/8000 - (1451*x)/1200 + 498/5

Ingrese el valor a interpolar x= 150


el valor interpolado es:

f =
883/80

APROXIMACION DE NEWTON
(DIFERENCIAS DIVIDIDAS)
function difdivid
clc,clear
X=[140 180 220 240];
F=[12.800 7.500 5.000 3.800];
N=length(X)-1;
syms x
I=1;
while I<=N
T(I,1)=(F(I+1)-F(I))/(X(I+1)-X(I));
I=I+1;
end
J=2;
while J<=N
I=J;
while I<=N
T(I,J)=(T(I,J-1)-T(I-1,J-1))/(X(I+1)-X(I+1-J));
I=I+1;
end
J=J+1;
end
in=F(1);
I=1;
while I<=N
P=1;
J=1;
while J<=I
P=P*(x-X(J));
J=J+1;
end
in=in+T(I,I)*P;
I=I+1;
disp(' El polinomio es: ')
disp(simplify(in));
xo=input(' Ingrese el valor a interpolar x=');
disp('el valor interpolado es:')
f=subs(in,xo)
end

EJECUTANDO PROGRAMA:
El polinomio es:
(7*(x - 140)*(x - 180))/8000 - (53*x)/400 - (4919131752989215*(x - 140)*(x - 180)*(x -
220))/590295810358705651712 + 627/20
Ingrese el valor a interpolar x=150
el valor interpolado es:

f=

4072118754271383503013/368934881474191032320

APROXIMACION DE NEWTON
DIFERENCIAS FINITAS (HACIA ADELANTE Y
HACIA ATRÁS)
function difint
clc,clear
X=[140 180 220];
FX=[12.800 7.500 5.000];
F=FX;
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=2;
xo=input('Ingrese el valor pivote x(0)=');
o=200;
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
fprintf(' El valor interpolado es: %f\n',p)

EJECUTANDO PROGRAMA:
-5.300000000000001 2.800000000000001
-2.500000000000000 0
Interpolación hacia; adelante=1 atrás=2 =1
Ingrese el valor pivote x(0)=140
El valor interpolado es: 5.900000

PROBLEMA CON VALOR FISICO 2:

Se presentan la temperatura de ebullición de la acetona (C3H60) a diferentes presiones.

Supóngase que sólo se dispusiera de la segunda y se desease calcular la temperatura de


ebullición de la acetona a 2 atm de presión.

%APROXIMACION POLINOMIAL SIMPLE E INTERPOLACION


clc
clear clc
disp(' sea la ecuacion P(X)=a0+a1*x+a2*x^2' )
%metodo doolitle L(1.1)=L(2.2)=L(3.3)=1
M=[1 1 1;1 5 25;1 20 400];
b=[56 113 181]';
%L*U=A
%PRIMERA FILA
u(1,1)=M(1,1);
u(1,2)=M(1,2);
u(1,3)=M(1,3);
%SEGUNDA FILA
u(2,1)=0;
l(2,1)=M(2,1)/u(1,1);
u(2,2)=M(2,2)-l(2,1)*u(1,2);
u(2,3)=M(2,3)-l(2,1)*u(1,3);
%TERCERA FILA
u(3,1)=0;
u(3,2)=0;
l(3,1)=M(3,1)/u(1,1);
l(3,2)=(M(3,2)-l(3,1)*u(1,2))/u(2,2);
u(3,3)=M(3,3)-l(3,1)*u(1,3)-l(3,2)*u(2,3);
L=[1 0 0;l(2,1) 1 0;l(3,1) l(3,2) 1];
U=[u(1,1) u(1,2) u(1,3);u(2,1) u(2,2) u(2,3);u(3,1) u(3,2) u(3,3)];
%L*C=b
C1=b(1);
C2=b(2)-L(2,1)*C1;
C3=b(3)-L(3,1)*C1-L(3,2)*C2;
C=[C1 C2 C3]';
%U*a=C
a2=C(3)/U(3,3);
a1=(C(2)-U(2,3)*a2)/U(2,2);
a0=(C(1)-U(1,2)*a1-U(1,3)*a2)/U(1,1);
a=[a0 a1 a2]'
X=input('ingrese el valor de x:');
disp('reemplazando x ')
P=a0+a1*X+a2*X^2

EJECUTANDO PROGRAMA:
sea la ecuacion P(X)=a0+a1*x+a2*x^2

a =

39.1930
17.3184
-0.5114

Ingrese el valor de x:2


Reemplazando x

P =

71.7842

%POLINOMIOS DE LAGRANGE
clc
clear clc
f0=input('ingrese el valor de f0:');
f1=input('ingrese el valor de f1:');
f2=input('ingrese el valor de f2:');
f3=input('ingrese el valor de f3:');
x0=input('ingrese el valor de x0:');
x1=input('ingrese el valor de x1:');
x2=input('ingrese el valor de x2:');
x3=input('ingrese el valor de x3:');
X=input('ingrese el valor de X:');
disp('sea la funcion P(x)=L0*f0+L1*f1+L2*f2+L3*f3')
L0=((X-x1)*(X-x2)*(X-x3))/((x0-x1)*(x0-x2)*(x0-x3));
L1=((X-x0)*(X-x2)*(X-x3))/((x1-x0)*(x1-x2)*(x1-x3));
L2=((X-x0)*(X-x1)*(X-x3))/((x2-x0)*(x2-x1)*(x1-x3));
L3=((X-x0)*(X-x1)*(X-x2))/((x3-x0)*(x3-x1)*(x3-x2));
P=(f0*L0)+(f1*L1)+(f2*L2)+(f3*L3)

EJECUTANDO PROGRAMA:
Ingrese el valor de f0:56.5
Ingrese el valor de f1:113
Ingrese el valor de f2:181
Ingrese el valor de f3:214.5
Ingrese el valor de x0:1
Ingrese el valor de x1:5
Ingrese el valor de x2:20
Ingrese el valor de x3:40
Ingrese el valor de X:2
Sea la función P(x)=L0*f0+L1*f1+L2*f2+L3*f3
P=
74.2768
%FRACCIONES DIVIDIDAS
clc
clear clc
X=[1 5 20 40];
F=[56.5 113 181 214.4];
A=4;
B=A-1;
for i=1:B
T(i,1)=(F(i+1)-F(i))/(X(i+1)-X(i));

end
for j=2:B
for i=j:B
T(i,j)=(T(i,j-1)-T(i-1,j-1))/(X(i+1)-X(i-j+1));
end
end
T

EJECUTANDO PROGRAMA:
T =
14.1250 0 0 0 0
4.5333 -0.5048 -2.5000 -1.2500 -0.6250
1.6700 -0.0818 0.0108 0.9375 0.5469
9.0000 3.0000 1.0000 0 -0.2375
45.0000 9.0000 1.0000 0 0

%APROXIMACION POLINOMIAL DE NEWTON


clc
clear clc
x=[1 5 20 40];
f=[56.5 113 181 214.5];
M=4;
N=M-1;
for i=1:3
T(i,1)=(f(i+1)-f(i))/(x(i+1)-x(i));
end
for j=2:N
for i=j:N
T(i,j)=(T(i,j-1)-T(i-1,j-1))/(x(i+1)-x(i-j+1));
end
end
T
disp('sea la funcion P(x)=a0+a1*(x-x0)+a2*(x-x0)*(x-x1)+a3*(x-x0)*(x-x1)*(x-
x2)')
X=input('ingrese el valor de x:');
a0=f(1,1);
a1=T(1,1);
a2=T(2,2);
a3=T(3,3);
P=a0+a1*(X-x(1,1))+a2*(X-x(1,1))*(X-x(1,2))+a3*(X-x(1,1))*(X-x(1,2))*(X-x(1,3))

EJECUTANDO PROGRAMA:
T =

14.1250 0 0 0 0
4.5333 -0.5048 -2.5000 -1.2500 -0.6250
1.6750 -0.0817 0.0109 0.9375 0.5469
9.0000 3.0000 1.0000 0 -0.2375
45.0000 9.0000 1.0000 0 0

Sea la función P(x)=a0+a1*(x-x0)+a2*(x-x0)*(x-x1)+a3*(x-x0)*(x-


x1)*(x-x2)
Ingrese el valor de x:2

P =
72.7254

También podría gustarte