Documentos de Académico
Documentos de Profesional
Documentos de Cultura
APROXIMACION E
NOVENA TAREA
INTERPOLACION
MÉTODOS NUMÉRICOS
CATEDRATICO:
IV SEMESTRE
HUANCAYO -2018
PROBLEMA CON VALOR FISICO 1:
1. Con los siguientes valores.
Puntos 0 1 2 3
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
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
EJECUTANDO PROGRAMA:
sea la ecuacion P(X)=a0+a1*x+a2*x^2
a =
39.1930
17.3184
-0.5114
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
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
P =
72.7254