数值分析-最小二乘法
最小二乘拟合多项式
\[ \varphi_{0}=1,\varphi_{1}=x,\varphi_{2}=x^2,……\varphi_{n}=x^n \] ## 例题 \[ x \quad -3\quad-2\quad-1\quad0\quad1\quad2\quad3\quad4 \] \[ f(x)\quad-3.2\quad-2.1\quad-1.2\quad0.1\quad0.9\quad2.1\quad3.3\quad4 \] 试用y=ax+b拟合
题解
\[ \begin{bmatrix} (\varphi_{0},\varphi_{0}) & (\varphi_{0},\varphi_{1}) \\ (\varphi_{1},\varphi_{0}) & (\varphi_{1},\varphi_{1}) \end{bmatrix} \begin{pmatrix} a_{0}\\ a_{1} \end{pmatrix}= \begin{pmatrix} (f,\varphi_{0})\\ (f,\varphi_{1}) \end{pmatrix} \] \[ \varphi_{0}=(1,1,1,1,1,1,1,1,1)' \] \[ \varphi_{1}=(-3,-2,-1,0,1,2,3,4)' \] \[ f=(-3.2,-2.1,-1.2,0.1,0.9,2.1,3.3,4)' \]
\[ a_{0}=a,a_{1}=b \] 可得: \[ \begin{bmatrix} 8 & 4 \\ 4 & 44 \end{bmatrix} \begin{pmatrix} a\\ b \end{pmatrix}= \begin{pmatrix} 3.9\\ 46 \end{pmatrix} \] 解得
a=1.048810,b=-0.036905
二次拟合即3by3 * 3by1=3by1,其中\(\varphi_{2}\)为每个x的平方组成的列向量