John Cagnol


Paris, France

Introduction au Calcul Scientifique
ESI CS 1402 - Printemps 2010

Calculs faits avec Maple dans le chapitre I

> n:=9;
x[1]:=20; x[2]:=40; x[3]:=60; x[4]:=80; x[5]:=100; x[6]:=120; x[7]:=140; x[8]:=160; x[9]:=180;
y[1]:=210; y[2]:=170; y[3]:=155; y[4]:=160; y[5]:=175; y[6]:=205; y[7]:=245; y[8]:=300; y[9]:=360;
9
20
40
60
80
100
120
140
160
180
210
170
155
160
175
205
245
300
360
> F := unapply(sum((y[i]-a*x[i]-b)^2, i = 1 .. n), [a, b]);
proc (a, b) options operator, arrow; `+`(`*`(`^`(`+`(210, `-`(`*`(20, `*`(a))), `-`(b)), 2)), `*`(`^`(`+`(170, `-`(`*`(40, `*`(a))), `-`(b)), 2)), `*`(`^`(`+`(155, `-`(`*`(60, `*`(a))), `-`(b)), 2)), ...
proc (a, b) options operator, arrow; `+`(`*`(`^`(`+`(210, `-`(`*`(20, `*`(a))), `-`(b)), 2)), `*`(`^`(`+`(170, `-`(`*`(40, `*`(a))), `-`(b)), 2)), `*`(`^`(`+`(155, `-`(`*`(60, `*`(a))), `-`(b)), 2)), ...
> simplify(F(a,b));
`+`(474900, `-`(`*`(444600, `*`(a))), `-`(`*`(3960, `*`(b))), `*`(114000, `*`(`^`(a, 2))), `*`(1800, `*`(a, `*`(b))), `*`(9, `*`(`^`(b, 2))))
> plot3d(F(a, b), a = 0..2, b = -100..300, view = 0..100000, axes = BOXED);
Plot
> solve({(D[1](F))(a,b)=0, (D[2](F))(a,b)= 0}, {a,b});
{a = `/`(81, 80), b = `/`(475, 4)}