Exercício 4.27 (a)

> X:=matrix(5,3,[1,1,1,1,2,4,1,3,9,1,4,16,1,5,25]);
b:=vector(5,[1.2,0.8,2.4,2.9,3.5]);

[Maple Math]

[Maple Math]

> XtX:=evalm(transpose(X)&*X);
Xtb:=evalm(transpose(X)&*b);

[Maple Math]

[Maple Math]

> sol:=vector(3,0):
sol:=Gauss(XtX,Xtb);

[Maple Math]

> p2:=sol[1]+sol[2]*x+sol[3]*x^2;

[Maple Math]

> with(student):
p2x:=makeproc(p2,x);

Warning, new definition for D

[Maple Math]

> with(plots):
pplot:=plot(p2x(x),x=1..5):
A:=pointplot({[1,b[1]],[2,b[2]],[3,b[3]],[4,b[4]],[5,b[5]]},axes=BOXED,symbol=circle,title="Exercício 4.27 (a)"):
display(pplot,A);

[Maple Plot]