Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Dada la función
4
f (x) =
Y los puntos 1 + x2
x0 = -3, x1 = -1, x2 = 1, x3 = 3
a) Hallar el polinomio de interpolación de Lagrange:
>> X=-3:2:3
X=
-3 -1 1 3
>> Y=4./(1+X.^2)
Y=
0.400000000000000 2.000000000000000 2.000000000000000 0.400000000000000
>> [C,L]=lagrange(X,Y)
C=
0 -0.200000000000000 0 2.200000000000000
L=
-0.020833333333333 0.062500000000000 0.020833333333333 -0.062500000000000
0.062500000000000 -0.062500000000000 -0.562500000000000 0.562500000000000
-0.062500000000000 -0.062500000000000 0.562500000000000 0.562500000000000
0.020833333333333 0.062500000000000 -0.020833333333333 -0.062500000000000
>>
3.5
3
>> x=-3:0.0002:3;
>> y=4./(1+x.^2);
>> y1=polyval(C,x); 2.5
>> plot(x,y,'k', x,y1,'r')
>> grid on 2
1.5
0.5
0
-3 -2 -1 0 1 2 3
c) Hallar el valor aproximado de f(1.8)
>> s=polyval(C,1.8)
s=
1.552000000000000
2. Dada la funci'on
4
f (x) =
1 + x2
y los puntos
>> X=-3:3
X=
-3 -2 -1 0 1 2 3
>> Y=4./(1+X.^2)
Y=
Columns 1 through 4
0.400000000000000 0.800000000000000 2.000000000000000 4.000000000000000
Columns 5 through 7
2.000000000000000 0.800000000000000 0.400000000000000
>> [C,L]=lagrange(X,Y)
C=
Columns 1 through 4
-0.040000000000000 0.000000000000000 0.600000000000000 0.000000000000000
Columns 5 through 7
-2.560000000000000 -0.000000000000000 4.000000000000000
L=
Columns 1 through 4
0.001388888888889 -0.004166666666667 -0.006944444444444 0.020833333333333
-0.008333333333333 0.016666666666667 0.083333333333333 -0.166666666666667
0.020833333333333 -0.020833333333333 -0.270833333333333 0.270833333333333
-0.027777777777778 0.000000000000000 0.388888888888889 0.000000000000000
0.020833333333333 0.020833333333333 -0.270833333333333 -0.270833333333333
-0.008333333333333 -0.016666666666667 0.083333333333333 0.166666666666667
0.001388888888889 0.004166666666667 -0.006944444444444 -0.020833333333333
Columns 5 through 7
0.005555555555556 -0.016666666666667 0
-0.075000000000000 0.150000000000000 0
0.750000000000000 -0.750000000000000 0
-1.361111111111111 -0.000000000000000 1.000000000000000
0.750000000000000 0.750000000000000 0
-0.075000000000000 -0.150000000000000 0
0.005555555555556 0.016666666666667 0
b) Grafique en un mismo sistema de coordenadas y = f (x) con color negro y
y = P6 (x) con color rojo.
>> x=-3:0.0002:3;
>> y=4./(1+x.^2);
>> y1=polyval(C,x);
>> plot(x,y,'k', x,y1,'r')
>> grid on
3.5
2.5
1.5
0.5
0
-3 -2 -1 0 1 2 3
>> s=polyval(C,1.8)
s=
0.643671040000002
3. Dada la función
f (x) = cos(x)
y los puntos
xO = 0, x1 = 2π/3, x2 = 4π/3, x3 = 2π
a) Hallar el polinomio de interpolación de Lagrange:P3 (x)
>> X=0:2*pi/3:2*pi
X=
0 2.094395102393195 4.188790204786391 6.283185307179586
>> Y=cos(X)
Y=
1.000000000000000 -0.500000000000000 -0.500000000000000 1.000000000000000
>> [C,L]=lagrange(X,Y)
C=
0.000000000000000 0.170979497396445 -1.074295865870294 1.000000000000000
L=
-0.018141488118675 0.227972663195260 -0.875352187005424 1.000000000000000
0.054424464356024 -0.569931657988150 1.432394487827058 0
-0.054424464356024 0.455945326390520 -0.716197243913529 0
0.018141488118675 -0.113986331597630 0.159154943091895 0
1.5
>>x=0:pi/100:2*pi;
>> y=cos(x); 1
>> y1=polyval(C,x);
>> plot(x,y,'k', x,y1,'r')
>> grid on
0.5
-0.5
-1
0 1 2 3 4 5 6 7
c) Hallar el valor aproximado de f (3π/4)
>> s=polyval(C,3*pi/4)
s=
-0.582031250000000
xO = 0, x1 = π/2, x2 = π, x3 =3π/2,x4=2π
y los puntos
>> X=0:pi/2:2*pi
X=
0 1.570796326794897 3.141592653589793 4.712388980384690 6.283185307179586
>> Y=cos(X)
Y=
1.000000000000000 0.000000000000000 -1.000000000000000 -0.000000000000000 1.000000000000000
>> [C,L]=lagrange(X,Y)
C=
-0.027375952679158 0.344016367287461 -1.148306747946495 0.424413181578388 1.000000000000000
L=
0.006843988169790 -0.107505114777332 0.591040237913637 -1.326291192432461 1.000000000000000
-0.027375952679158 0.387018413198394 -1.756233849800521 2.546479089470326 0
0.041063929018737 -0.516024550931192 1.925102489204418 -1.909859317102744 0
-0.027375952679158 0.301014321376529 -0.945664380661819 0.848826363156775 0
0.006843988169790 -0.064503068866399 0.185755503344286 -0.159154943091895 0
1.5
1
>> x=0:pi/100:2*pi;
>> y=cos(x);
>> y1=polyval(C,x);
0.5
>> plot(x,y,'k', x,y1,'r')
>> grid on
0
-0.5
-1
-1.5
0 1 2 3 4 5 6 7
d) Hallar el valor aproximado de f (3π/4)
>> s=polyval(C,3*pi/4)
s=
-0.718750000000002
>> x=3:0.01:8;
>> y1=polyval(C,x);
>> plot(x,y1,'r')
>> grid on
140
120
100
80
60
40
20
0
3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8
>> s=polyval(C,4.4)
s=
39.503033143628272
6. Dada la funci'on
f (x) = x3- 6 x2 + 8x - 2
>> x=-2:0.01:6;
>> y=x.^3-6*x.^2+8*x-2;
>> y1=polyval(C,x);
>> plot(x,y,'k',x,y1,'r')
>> grid on
50
40
30
20
10
-10
-20
-30
-40
-50
-2 -1 0 1 2 3 4 5 6
c) Si se tienen los puntos
xO = -2, x1 = 2, x2 = 6
>> x=-2:0.01:6;
>> y=x.^3-6*x.^2+8*x-2;
>> y1=polyval(C,x);
>> plot(x,y,'k',x,y1,'r')
>> grid on
50
40
30
20
10
-10
-20
-30
-40
-50
-2 -1 0 1 2 3 4 5 6
e) Si se tienen los puntos
xO = -2, x1 = 0, x2 = 2, x3 = 4, x4 = 6
40
>> x=-2:0.01:6; 30
>> y=x.^3-6*x.^2+8*x-2;
>> y1=polyval(C,x); 20
>> plot(x,y,'k',x,y1,'r')
>> grid on 10
-10
-20
-30
-40
-50
-2 -1 0 1 2 3 4 5 6