A=(({{5, 10}, {10, 30}}));
b={8,20};
LinearSolve[A,b]

A=(({{5, 10, 30}, {10, 30, 100}, {30, 100, 354}}));
b={8,20,70};
LinearSolve[A,b]//N

xp={0,1,2,3,4};
yp ={1,2,1,0,4};
n=Length[xp];
points=Table[{xp[[i]],yp[[i]]},{i,n}];
grfp=ListPlot[points,PlotStyle->{Black,PointSize[0.02]}]

P1[x_]:=(2/5)x+(4/5)
grfP1=Plot[P1[x],{x,0,4},PlotStyle->Red]

P2[x_]:=0.42857(x^2)-1.31429x+1.65714
grfP2=Plot[P2[x],{x,0,4},PlotStyle->Blue]

Show[grfp,grfP1,grfP2]

съставяне на програмен код:

xp={0,1,2,3,4};
yp ={1,2,1,0,4};
n=Length[xp];
points=Table[{xp[[i]],yp[[i]]},{i,n}];
grfp=ListPlot[points,PlotStyle->{Black,PointSize[0.02]}];
(* съставяме полином от първа степен - линейна регресия *)
A1 = (({{n, (∑_(i=1)^n)xp[[i]]}, {(∑_(i=1)^n)xp[[i]], (∑_(i=1)^n)(((xp[[i]]))^2)}}));
b1={(∑_(i=1)^n)yp[[i]],(∑_(i=1)^n)xp[[i]]yp[[i]]};
a1=LinearSolve[A1,b1];
P1[x_]:=a1[[2]]x+a1[[1]]
grfP1=Plot[P1[x],{x,0,4},PlotStyle->Red];
(* съставяме полином от втора степен - квадратична регресия *)
A2 = (({{n, (∑_(i=1)^n)xp[[i]], (∑_(i=1)^n)(((xp[[i]]))^2)}, {(∑_(i=1)^n)xp[[i]], (∑_(i=1)^n)(((xp[[i]]))^2), (∑_(i=1)^n)(((xp[[i]]))^3)}, {(∑_(i=1)^n)(((xp[[i]]))^2), (∑_(i=1)^n)(((xp[[i]]))^3), (∑_(i=1)^n)(((xp[[i]]))^4)}}));
b2={(∑_(i=1)^n)yp[[i]],(∑_(i=1)^n)xp[[i]]yp[[i]], (∑_(i=1)^n)(((xp[[i]]))^2)yp[[i]]};
a2=LinearSolve[A2,b2];
P2[x_]:=a2[[3]](x^2)+a2[[2]]x+a2[[1]]
grfP2=Plot[P2[x],{x,0,4},PlotStyle->Blue];
Show[grfp,grfP1,grfP2]