Está en la página 1de 10

1.

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
>>

b) Grafique en un mismo sistema de coordenadas y = f (x) con color negro y


y = P3 (x) con color rojo.

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

xO = -3, x1 = -2, x2 = -1, x3 = 0, x4 = 1, x5 = 2, x6 = 3

a) Hallar el polinomio de interpolación de Lagrange: P6 (x)

>> 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

c) Hallar el valor aproximado de f(1.8)

>> 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

b) Grafique en un mismo sistema de coordenadas y = f (x) con color negro y


y = P3 (x) con color rojo.

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

4. Dada la función f (x) = cos(x)

xO = 0, x1 = π/2, x2 = π, x3 =3π/2,x4=2π
y los puntos

a) Hallar el polinomio de interpolacion de Lagrange: P4 (x)

>> 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

b) Grafique en un mismo sistema de coordenadas y = f (x) con color negro y


y = P4 (x) con color rojo.

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

5. Para calibrar un medidor de orificio se miden la velocidad v de un fluido y la ca'ida


de presi'on P . Los datos experimentales se muestran en la siguiente tabla:

v 3.83 4.17 4.97 6.06 6.71 7.17 7.51 7.98


P 30 35.5 50.5 75 92 105 115 130

a) Hallar el polinomio de interpolacion de Lagrange:


>> X=[3.83 4.17 4.97 6.06 6.71 7.17 7.51 7.98]
X=
Columns 1 through 4
3.830000000000000 4.170000000000000 4.970000000000000 6.060000000000000
Columns 5 through 8
6.710000000000000 7.170000000000000 7.510000000000000 7.980000000000000
>> Y=[30 35.5 50.5 75 92 105 115 130]
Y=
1.0e+002 *
Columns 1 through 4
0.300000000000000 0.355000000000000 0.505000000000000 0.750000000000000
Columns 5 through 8
0.920000000000000 1.050000000000000 1.150000000000000 1.300000000000000
>> [C,L]=lagrange(X,Y)
C=
1.0e+003 *
Columns 1 through 4
0.000018623335861 -0.000746282972950 0.012672198204207 -0.118161291466095
Columns 5 through 8
0.653249209125293 -2.138717659617774 3.849972805252299 -2.931046747291461
L=
1.0e+004 *
Columns 1 through 4
-0.000000787547031 0.000035100971175 -0.000665933230981 0.006968479740181
0.000002006055194 -0.000088727821245 0.001668722971008 -0.017288418336990
-0.000003437213607 0.000149278186964 -0.002751266073735 0.027871472641335
0.000010836805245 -0.000458830334083 0.008232739367378 -0.081093005590340
-0.000025861853729 0.001078180681949 -0.019048346641406 0.184775293144812
0.000032260036265 -0.001330081295187 0.023248614514506 -0.223231340196756
-0.000017279741198 0.000706568617603 -0.012254761354378 0.116825285724848
0.000002263458861 -0.000091489007175 0.001570230447608 -0.014827767127090
Columns 5 through 8
-0.043418267441678 0.161000313310509 -0.328818495950596 0.285184600537746
0.106486604392315 -0.389636147883857 0.783485212633460 -0.667198665578268
-0.167460008268909 0.596176188774591 -1.163377030217484 0.959176389098043
0.473270277097905 -1.635589563706434 3.097904856221707 -2.480144531922901
-1.062383553118359 3.619189889278249 -6.762374336887168 5.345464835412831
1.271224148809511 -4.292091374009087 7.953857293727457 -6.240135808202646
-0.660887038437674 2.217929597590855 -4.087666734047015 3.191138419996314
0.083167836966889 -0.276978903354827 0.506989234519641 -0.393385239341118
b) Grafique el polinomio y = P7 (x).

>> 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

c) Hallar el valor aproximado d e la presi'on correspondiente a la velocidad v=4.4

>> s=polyval(C,4.4)
s=
39.503033143628272
6. Dada la funci'on
f (x) = x3- 6 x2 + 8x - 2

a) Si se tienen los puntos


xO = -2, x1 = 6
hallar el polinomio de interpolaci'on de Lagrange:
Pl (x)
>> X=[-2 6]
X=
-2 6
>> Y=X.^3-6*X.^2+8*X-2
Y=
-50 46
>> [C,L]=lagrange(X,Y)
C=
12 -26
L=
-0.125000000000000 0.750000000000000
0.125000000000000 0.250000000000000

b) Grafique en un mismo sistema de coordenadas y = f (x) con color negro y


y = Pl (x) con color rojo.

>> 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

hallar el polinomio de interpolación de Lagrange:


P2 (x)
>> X=-2:4:6
X=
-2 2 6
>> Y=X.^3-6*X.^2+8*X-2
Y=
-50 -2 46
>> [C,L]=lagrange(X,Y)
C=
0 12 -26
L=
0.031250000000000 -0.250000000000000 0.375000000000000
-0.062500000000000 0.250000000000000 0.750000000000000
0.031250000000000 0 -0.125000000000000

d) Grafique en un mismo sistema de coordenadas y = f (x) con color negro y


y = P2 (x) con color rojo

>> 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

hallar el polinomio de interpolación de Lagrange:


P4 (x)
>> X=-2:2:6
X=
-2 0 2 4 6
>> Y=X.^3-6*X.^2+8*X-2
Y=
-50 -2 -2 -2 46
>> [C,L]=lagrange(X,Y)
C=
Columns 1 through 4
0.000000000000000 1.000000000000000 -6.000000000000000 8.000000000000000
Column 5
-2.000000000000000
L=
Columns 1 through 4
0.002604166666667 -0.031250000000000 0.114583333333333 -0.125000000000000
-0.010416666666667 0.104166666666667 -0.208333333333333 -0.416666666666667
0.015625000000000 -0.125000000000000 0.062500000000000 0.750000000000000
-0.010416666666667 0.062500000000000 0.041666666666667 -0.250000000000000
0.002604166666667 -0.010416666666667 -0.010416666666667 0.041666666666667
Column 5
0
1.000000000000000
0
0
0
f ) Grafique en un mismo sistema de coordenadas y = f (x) con color negro y
y = P4 (x) con color rojo. 50

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

También podría gustarte