C 0.1905 X - 0.7619 X - 0.9524 X + 4.0000: %graficas de F y El Polinomio
C 0.1905 X - 0.7619 X - 0.9524 X + 4.0000: %graficas de F y El Polinomio
C 0.1905 X - 0.7619 X - 0.9524 X + 4.0000: %graficas de F y El Polinomio
clear
X=[-2 0 2 4]
Y=4./(X.^2+X+1)
[C, L] = lagrange(X,Y)
%Graficas de f y el polinomio
x=[-2:0.01:4];
y=4./(x.^2+x+1);
y1=polyval(C,x);
plot(x,y,'r','linewidth',2)
hold on
plot(x,y1,'k','linewidth',2)
grid on
hold off
k=polyval(C,1.8)
X=
-2 0 2 4
Y=
C=
0.1905 x3 - 0.7619 x2 - 0.9524 x + 4.0000
L=
0.0208 0 -0.0833 0
k=
0.9280
6
-1
-2 -1 0 1 2 3 4
Pregunta 02:
clc
clear
X=[-2:4]
Y=4./(X.^2+X+1)
[C, L] = lagrange(X,Y)
%Graficas de f y el polinomio
x=[-2:0.01:4];
y=4./(x.^2+x+1);
y1=polyval(C,x);
plot(x,y,'r','linewidth',2)
hold on
plot(x,y1,'k','linewidth',2)
grid on
hold off
k=polyval(C,1.8)
6
-1
-2 -1 0 1 2 3 4
X=
-2 -1 0 1 2 3 4
Y=
C=
L=
k=
0.5576
Pregunta 03:
clc
clear
X=[0:pi/2:2*pi]
Y=4*cos(2*X)+6*sin(X)
[C, L] = lagrange(X,Y)
%Graficas de f y el polinomio
x=[0:pi/100:2*pi];
y=4*cos(2*x)+6*sin(x);
y1=polyval(C,x);
plot(x,y,'r','linewidth',2)
hold on
plot(x,y1,'k','linewidth',2)
grid on
hold off
k=polyval(C,3*pi/7)
X =
0 1.5708 3.1416 4.7124 6.2832
Y =
4.0000 2.0000 4.0000 -10.0000 4.0000
C =
0.4380 -4.9882 16.7518 -16.9765 4.0000
L =
0.0068 -0.1075 0.5910 -1.3263 1.0000
-0.0274 0.3870 -1.7562 2.5465 0
0.0411 -0.5160 1.9251 -1.9099 0
-0.0274 0.3010 -0.9457 0.8488 0
0.0068 -0.0645 0.1858 -0.1592 0
k =
0.7747
6
-2
-4
-6
-8
-10
-12
-14
0 1 2 3 4 5 6 7
Pregunta 04:
clc
clear
X=[0:pi/4:2*pi]
Y=4*cos(2*X)+6*sin(X)
[C, L] = lagrange(X,Y)
%Graficas de f y el polinomio
x=[0:pi/100:2*pi];
y=4*cos(2*x)+6*sin(x);
y1=polyval(C,x);
plot(x,y,'r','linewidth',2)
hold on
plot(x,y1,'k','linewidth',2)
grid on
hold off
k=polyval(C,3*pi/7)
6
-2
-4
-6
-8
-10
0 1 2 3 4 5 6 7
X=
Y=
C=
0.0110 -0.2746 2.7255 -13.5405 35.0117 -44.3295 22.3504 -2.4624 4.0000
L=
k=
2.3016
Pregunta 05:
clc
clear
X=[-2 0 2 4]
Y=exp(X./4).*(X-3).^2
[C, L] = lagrange(X,Y)
%Graficas de f y el polinomio
x=[-2:0.01:4];
y= exp(x./4).*(x-3).^2;
y1=polyval(C,x);
plot(x,y,'r','linewidth',2)
hold on
plot(x,y1,'k','linewidth',2)
grid on
hold off
k=polyval(C,2.7)
X=
-2 0 2 4
Y=
C=
L=
0.0208 0 -0.0833 0
k=
0.5733
16
14
12
10
0
-2 -1 0 1 2 3 4
Pregunta 06:
clc
clear
X=[-2 6]
Y=X.^3/4-7*X.^2+10*X-15
[C, L] = lagrange(X,Y)
%Graficas de f y el polinomio
x=[-2:0.01:6];
y=x.^3/4-7*x.^2+10*x-15;
y1=polyval(C,x);
plot(x,y,'r','linewidth',2)
hold on
plot(x,y1,'k','linewidth',2)
grid on
hold off
X=
-2 6
Y=
-65 -153
C=
-11 -87
L=
-0.1250 0.7500
0.1250 0.2500
0
-20
-40
-60
-80
-100
-120
-140
-160
-2 -1 0 1 2 3 4 5 6
clc
clear
X=[-2 2 6]
Y=X.^3/4-7*X.^2+10*X-15
[C, L] = lagrange(X,Y)
%Graficas de f y el polinomio
x=[-2:0.01:6];
y=x.^3/4-7*x.^2+10*x-15;
y1=polyval(C,x);
plot(x,y,'r','linewidth',2)
hold on
plot(x,y1,'k','linewidth',2)
grid on
hold off
X=
-2 2 6
Y=
C=
L=
0.0313 0 -0.1250
0
-20
-40
-60
-80
-100
-120
-140
-160
-2 -1 0 1 2 3 4 5 6
clc
clear
X=[-2 0 2 4 6]
Y=X.^3/4-7*X.^2+10*X-15
[C, L] = lagrange(X,Y)
%Graficas de f y el polinomio
x=[-2:0.01:6];
y=x.^3/4-7*x.^2+10*x-15;
y1=polyval(C,x);
plot(x,y,'r','linewidth',2)
hold on
plot(x,y1,'k','linewidth',2)
grid on
hold off
X=
-2 0 2 4 6
Y=
C=
L=
-20
-40
-60
-80
-100
-120
-140
-160
-2 -1 0 1 2 3 4 5 6