Afsnit 19.5 opgave 10

Hooke's lov

x={0.9,0.5,1.6,2.1}; y={10,5,15,20};

m=Table[{x[[i]],y[[i]]},{i,4}]

g1=ListPlot[m, 
PlotStyle->{PointSize[0.02],RGBColor[1,0,0]}]

g2=ListPlot[m, PlotJoined->True,
PlotStyle->{RGBColor[0,1,0]}]

Show[g1,g2]

sx=0; Do[sx=sx+x[[i]],{i,4}]

sx2=0; Do[sx2=sx2+x[[i]]^2,{i,4}]

sy=0; Do[sy=sy+y[[i]],{i,4}]

sxy=0; Do[sxy=sxy+x[[i]] y[[i]],{i,4}]

sm={{4,sx},{sx,sx2}};

MatrixForm[sm]

r={sy,sxy}

v={a,b}; Solve[sm .  v==r,v]

v /. %;

v=%; a=v[[1,1]];k=v[[1,2]];

F[s_] = a + k s

g3=Plot[F[x],{x,0,3}]

Show[g1,g3]

k = 9.00164 (N/m), men bemaerk at linien ikke gaar gennem (0,0)
(a er forskellig fra 0).  Fejlen kan vaere reel. 
Det ka fx vaere en nulpunktsfejl paa dynamometeret.