Exercício 4.13

> f:=x->(4*x-7)/(x-2);
plot(f(x),x=-1..1);

[Maple Math]

[Maple Plot]

> n:=2;
m:=n+1;
#a:=0;
#b:=1.5;
#X:=vector(m,k->evalf((a+b)/2+(b-a)/2*cos(((2*k-1)*Pi)/(2*m))));
X:=vector(m,k->evalf(cos(((2*k-1)*Pi)/(2*m))));
fX:=vector(m,[f(X[1]),f(X[2]),f(X[3])]);

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> #plotf:=plot(f(x),x=a..b,color=blue):
plotf:=plot(f(x),x=-1..1,color=blue):
A:=pointplot({[X[1],fX[1]],[X[2],fX[2]],[X[3],fX[3]]},axes=BOXED,symbol=cross):
#B:=pointplot({[X[1],0],[X[2],0],[X[3],0]},axes=BOXED,symbol=circle):

> with(linalg):
poliLagrange:=Lagrange(X,fX);
p:=x->poliLagrange:
#plotLagrange:=plot(p(x),x=a..b):
plotLagrange:=plot(p(x),x=-1..1):
LagrangePt(0.5,X,fX);
f(0.5);

[Maple Math]

[Maple Math]

[Maple Math]

> #display(plotf,plotLagrange,A,B);
display(plotf,plotLagrange,A);

[Maple Plot]

> n:=3;
m:=n+1;
a:=0;
b:=1.5;
X:=vector(m,k->evalf((a+b)/2+(b-a)/2*cos(((2*k-1)*Pi)/(2*m))));
fX:=vector(m,[f(X[1]),f(X[2]),f(X[3]),f(X[4])]);

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> poliNewton:=PoliNewton(X,fX,10);
pNewton:=x->poliNewton:
plotNewton:=plot(pNewton(x),x=a..b):
PoliNewtonPt(0.5,X,fX,10);

[Maple Math]

[Maple Math]

> display(plotf,plotNewton);

[Maple Plot]

>