генериране на таблична функция:

xt=Table[-2+i(0.2),{i,0,10}]

f[x_]:=Log[(x^2)+5]
yt=f[xt]

linear regression

xt[[2]]

nn=Length[xt]
(∑_(i=1)^nn)xt[[i]]

(∑_(i=1)^nn)yt[[i]]

xt^2

(∑_(i=1)^nn)(((xt[[i]]))^2)

xt*yt

(∑_(i=1)^nn)xt[[i]]*yt[[i]]

A=(({{11, -11}, {-11, 15.4}}));b = {20.2,-21.541};
LinearSolve[A,b]

P1[x_]:=-0.305x+1.532

Plot[{f[x],P1[x]},{x,-2,0}]

намиране на апроксимацията (приближената стойност) в точката -1.723

P1[-1.723]

R1=(Sqrt[(∑_(i=1)^nn)(((yt[[i]]-P1[xt[[i]]]))^2)])

quadratic regression

xt^3

(∑_(i=1)^nn)(((xt[[i]]))^3)

xt^4

(∑_(i=1)^nn)(((xt[[i]]))^4)

(xt^2)*yt

(∑_(i=1)^nn)(((xt[[i]]))^2)yt[[i]]

A=(({{11, -11, 15.4}, {-11, 15.4, -24.2}, {15.4, -24.2, 40.533}}));b = {20.2,-21.541,31.116};
LinearSolve[A,b]

P2[x_]:=0.112(x^2)+-0.0804x+1.5988

Plot[{f[x],P2[x]},{x,-2,0}]

P2[-1.723]

R1=(Sqrt[(∑_(i=1)^nn)(((yt[[i]]-P2[xt[[i]]]))^2)])