Anda di halaman 1dari 6

UNIVERSIDAD TÉCNICA DE AMBATO

FACULTAD DE INGENIERÍA EN SISTEMAS, ELECTRÓNICA E INDUSTRIAL


CARRERA DE INGENIERÍA ELECTRÓNICA Y COMUNICACIONES
PERÍODO ACADÉMICO: SEPTIEMBRE 2017 – FEBRERO 2018
METODOS NUMERICOS

INTERPOLACIÓN DE NEWTON

Programación:

%Interpolación de newton
clear;clc;
disp('metodos numericos');
disp('interpolacion');
n=input('ingrese el grado del polinomio, n=');
fprintf('Se necesitan %.0f puntos\n',n+1);
disp('ingrese los puntos');
for i=1:n+1
fprintf('x%.0f=',i-1);
X(i)=input(' ');
fprintf('y%.0f=',i-1);
Y(i)=input(' ');
end
DD=zeros(n+1);
DD(:,1)=Y;
for k=2:n+1
for J=k:n+1
DD(J,k)=[DD(J,k-1)-DD(J-1,k-1)]/[X(J)-X(J-k+1)];
end
end
disp('La matriz de diferencias divididas es:');
disp(DD);
disp('El polinomio de newton es');
syms x;
polnew=DD(1,1);
P=1;
for i=1:n
P=P*(x-X(i));
polnew=polnew+P*DD(i+1,i+1);
end
polnew=expand(polnew);
pretty(polnew);
x=input('ingrese el valor de x a interpolar, x=');
vi=eval(polnew);
fprintf('el valor interpolado es %.2f\n',vi);
hold on;
ezplot(polnew,[X(1) X(n+1)]);
plot(x,vi,'r+');

Ejercicios:

1) Dado los puntos encuentre el Polinomio de Newton e interpolar x=3

𝑿𝟎 , 𝒀𝟎 𝑿𝟏 , 𝒀𝟏 𝑿𝟐 , 𝒀𝟐 𝑿𝟑 , 𝒀𝟑 𝑿𝟒 , 𝒀𝟒
X 0 3 2 5 6
Y 0 1 4 5 8

1
UNIVERSIDAD TÉCNICA DE AMBATO
FACULTAD DE INGENIERÍA EN SISTEMAS, ELECTRÓNICA E INDUSTRIAL
CARRERA DE INGENIERÍA ELECTRÓNICA Y COMUNICACIONES
PERÍODO ACADÉMICO: SEPTIEMBRE 2017 – FEBRERO 2018
METODOS NUMERICOS

La matriz de diferencias divididas es:

x y
0 0 0 0 0 0
3 1 0.3333 0 0 0
2 4 -3 -1.667 0 0
5 5 0.3333 1.6667 0.6667 0
6 8 3 0.6667 -0.3333 -0.1667

𝑏0 = 0

𝑓(𝑥1 ) − 𝑓(𝑥0 ) −3 − 𝑏1 1.6667 − 𝑏2


𝑏1 = 𝑏2 = 𝑏3 =
𝑥1 − 𝑥0 𝑥2 − 𝑥0 𝑥3 − 𝑥0

1−0 1 −3 − 0.3333 1.6667 − (−1.6667)


𝑏1 = = = 0.3333 𝑏2 = = −1.6667 𝑏3 = = 0.6667
3−0 3 2−0 5−0

−0.3333 − 𝑏3
𝑏4 =
𝑥4 − 𝑥0

−0.3333 − 0.6667
𝑏4 = = −0.1667
6−0

𝑓4 (𝑥) = 𝑏0 + 𝑏1 (𝑥 − 𝑥0 ) + 𝑏2 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) + 𝑏3 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) + 𝑏4 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) (𝑥 − 𝑥3 )

𝑓4 (𝑥) = 0 + 0.3333(𝑥 − 0) − 1.6667(𝑥 − 0)(𝑥 − 3) + 0.6667(𝑥 − 0)(𝑥 − 3)(𝑥 − 2) − 0.1667(𝑥 − 0)(𝑥 − 3)(𝑥 − 2)(𝑥 − 5)

𝒙𝟒 𝟕𝒙𝟑 𝟔𝟏𝒙𝟐 𝟒𝟑𝒙


𝒇𝟒 (𝒙) = − + − +
𝟔 𝟑 𝟔 𝟑

Ingrese el valor de x a interpolar, 𝑥 = 3

𝑥 4 7𝑥 3 61𝑥 2 43𝑥
𝑓(𝑥) = − + − +
6 3 6 3

(3)4 7(3)3 61(3)2 43(3)


𝑓(3) = − + − +
6 3 6 3

𝑓(3) = 1

El valor interpolado es 1

2) Dado los puntos encuentre el Polinomio de Newton e interpolar x=2

𝑿𝟎 , 𝒀𝟎 𝑿𝟏 , 𝒀𝟏 𝑿𝟐 , 𝒀𝟐 𝑿𝟑 , 𝒀𝟑
X 1 5 3 7
y 2 6 4 1

2
UNIVERSIDAD TÉCNICA DE AMBATO
FACULTAD DE INGENIERÍA EN SISTEMAS, ELECTRÓNICA E INDUSTRIAL
CARRERA DE INGENIERÍA ELECTRÓNICA Y COMUNICACIONES
PERÍODO ACADÉMICO: SEPTIEMBRE 2017 – FEBRERO 2018
METODOS NUMERICOS

La matriz de diferencias divididas es:

X y
1 2 0 0 0
5 6 1 0 0
3 4 1 0 0
7 1 -0.75 -0.875 -0.1458
Polinomio de Newton:

𝟕𝒙𝟑 𝟐𝟏𝒙𝟐 𝟏𝟏𝟑𝒙 𝟓𝟏


𝒇𝟑 (𝒙) = − + − +
𝟒𝟖 𝟏𝟔 𝟒𝟖 𝟏𝟔

Ingrese el valor de x a interpolar, 𝑥 = 2

7𝑥 3 21𝑥 2 113𝑥 51
𝑓(𝑥) = − + − +
48 16 48 16

7(2)3 21(2)2 113(2) 51


𝑓(2) = − + − +
48 16 48 16

𝑓(2) = 2.56

3) Dado los puntos encuentre el Polinomio de Newton e interpolar x=4

𝑿𝟎 , 𝒀𝟎 𝑿𝟏 , 𝒀𝟏 𝑿𝟐 , 𝒀𝟐 𝑿𝟑 , 𝒀𝟑
X 8 2 6 7
y 4 1 3 5

La matriz de diferencias divididas es:

x Y
8 4 0 0 0
2 1 1 0 0
6 3 1 0 0
7 5 -0.75 -0.875 -0.1458
Polinomio de Newton:

𝟑𝒙𝟑 𝟐𝟒𝒙𝟐 𝟐𝟐𝟑𝒙 𝟏𝟒𝟒


𝒇𝟑 (𝒙) = − + − +
𝟏𝟎 𝟓 𝟏𝟎 𝟓

Ingrese el valor de x a interpolar, 𝑥 = 4

3𝑥 3 24𝑥 2 223𝑥 144


𝑓3 (𝑥) = − + − +
10 5 10 5

3(4)3 24(4)2 223(4) 144


𝑓(4) = − + − +
10 5 10 5

3
UNIVERSIDAD TÉCNICA DE AMBATO
FACULTAD DE INGENIERÍA EN SISTEMAS, ELECTRÓNICA E INDUSTRIAL
CARRERA DE INGENIERÍA ELECTRÓNICA Y COMUNICACIONES
PERÍODO ACADÉMICO: SEPTIEMBRE 2017 – FEBRERO 2018
METODOS NUMERICOS

𝑓(4) = −2.80

4) Dado los puntos encuentre el Polinomio de Newton e interpolar x=3

𝑿𝟎 , 𝒀𝟎 𝑿𝟏 , 𝒀𝟏 𝑿𝟐 , 𝒀𝟐
X 5 2 6
Y 4 9 3

La matriz de diferencias divididas es:

x Y
5 4 0 0
2 9 -1.6667 0
6 3 -1.5 0.1667
Polinomio de Newton:

𝒙𝟐 𝟏𝟕𝒙
𝒇𝟐 (𝒙) = − + 𝟏𝟒
𝟔 𝟔

Ingrese el valor de x a interpolar, 𝑥 = 3

𝑥 2 17𝑥
𝑓2 (𝑥) = − + 14
6 6

(3)2 17(3)
𝑓(3) = − + 14
6 6

𝑓(3) = 7

5) Dado los puntos encuentre el Polinomio de Newton e interpolar x=6

𝑿𝟎 , 𝒀𝟎 𝑿𝟏 , 𝒀𝟏 𝑿𝟐 , 𝒀𝟐
X 15 12 16
Y 14 19 13

La matriz de diferencias divididas es:

X Y
15 14 0 0
12 19 -1.6667 0
16 13 -1.5 0.1667
Polinomio de Newton:

𝒙𝟐 𝟑𝟕𝒙
𝒇𝟐 (𝒙) = − + 𝟔𝟗
𝟔 𝟔

4
UNIVERSIDAD TÉCNICA DE AMBATO
FACULTAD DE INGENIERÍA EN SISTEMAS, ELECTRÓNICA E INDUSTRIAL
CARRERA DE INGENIERÍA ELECTRÓNICA Y COMUNICACIONES
PERÍODO ACADÉMICO: SEPTIEMBRE 2017 – FEBRERO 2018
METODOS NUMERICOS

Ingrese el valor de x a interpolar, 𝑥 = 6

𝑥 2 17𝑥
𝑓2 (𝑥) = − + 69
6 6

(6)2 17(6)
𝑓(6) = − + 69
6 6

𝑓(6) = 3

INTERPOLACIÓN LINEAL

Programación:

1)

x=[0.5 1 1.5 2 2.5 3 3.5 4 4.5 5];


y=[2 6 5 1 4 8 3 9 7 3];
xx=[1.0 2.0 3.0 4.0 5.0];
yy=interp1(x,y,xx,'linear');
disp([xx' yy'])
hold on
plot(x,y,'-bo','markersize',3,'markerfacecolor','b')
plot(xx,yy,'ro','markersize',4,'markerfacecolor','r')
xlabel('x')
ylabel('y')
grid on
title('Interpolación lineal');
hold off

2)

x=[1 2 3 4 5 6 7];
y=[5 9 6 1 4 3 6];
xx=[1.0 2.0 3.0 4.0 5.0];
yy=interp1(x,y,xx,'linear');
disp([xx' yy'])
hold on
plot(x,y,'-bo','markersize',3,'markerfacecolor','b')
plot(xx,yy,'ro','markersize',4,'markerfacecolor','r')
xlabel('x')
ylabel('y')
grid on
title('Interpolación lineal');
hold off

3)
x=[2 4 6 8 10 12];
y=[3 6 9 5 2 4];
xx=[1.0 2.0 3.0 4.0 5.0];
yy=interp1(x,y,xx,'linear');
disp([xx' yy'])
hold on
plot(x,y,'-bo','markersize',3,'markerfacecolor','b')
plot(xx,yy,'ro','markersize',4,'markerfacecolor','r')

5
UNIVERSIDAD TÉCNICA DE AMBATO
FACULTAD DE INGENIERÍA EN SISTEMAS, ELECTRÓNICA E INDUSTRIAL
CARRERA DE INGENIERÍA ELECTRÓNICA Y COMUNICACIONES
PERÍODO ACADÉMICO: SEPTIEMBRE 2017 – FEBRERO 2018
METODOS NUMERICOS

xlabel('x')
ylabel('y')
grid on
title('Interpolación lineal');
hold off

4)

x=[0.2 0.4 1 1.5 2.5 3 5];


y=[3 6 9 5 2 4 7];
xx=[1.0 2.0 3.0 4.0 5.0];
yy=interp1(x,y,xx,'linear');
disp([xx' yy'])
hold on
plot(x,y,'-bo','markersize',3,'markerfacecolor','b')
plot(xx,yy,'ro','markersize',4,'markerfacecolor','r')
xlabel('x')
ylabel('y')
grid on
title('Interpolación lineal');
hold off

5)

x=[1.3 1.8 2.6 3 3.9 4.2 5.2];


y=[2 6 9 1 2 3 6];
xx=[1.0 2.0 3.0 4.0 5.0];
yy=interp1(x,y,xx,'linear');
disp([xx' yy'])
hold on
plot(x,y,'-bo','markersize',3,'markerfacecolor','b')
plot(xx,yy,'ro','markersize',4,'markerfacecolor','r')
xlabel('x')
ylabel('y')
grid on
title('Interpolación lineal');
hold off

Anda mungkin juga menyukai