Mark Yourself Question
Find the function of form c1sin(x)+c2cos(x)c_1\sin(x)+c_2\cos(x)c1sin(x)+c2cos(x) which best fits the data points (−π,−3),(0,−4),(π/2,−5)(-\pi,-3),(0,-4),(\pi/2,-5)(−π,−3),(0,−4),(π/2,−5) in the least squares sense.
Solution:
M=[sin(−π)cos(−π)sin(0)cos(0)sin(π/2)cos(π/2)]=[0−10110],y⃗=[−3−4−5],MTM=[1002],MTy⃗=[−5−1]M=\left[\begin{array}{ll}\sin(-\pi)&\cos(-\pi)\\\sin(0)&\cos(0)\\\sin(\pi/2)&\cos(\pi/2)\end{array}\right]=\left[\begin{array}{rr}0&-1\\0&1\\1&0\end{array}\right],\vec y=\left[\begin{array}{r}-3\\-4\\-5\end{array}\right],M^TM=\left[\begin{array}{rr}1&0\\0&2\end{array}\right],M^T\vec y=\left[\begin{array}{r}-5\\-1\end{array}\right]M=sin(−π)sin(0)sin(π/2)cos(−π)cos(0)cos(π/2)=001−110,y=−3−4−5,MTM=[1002],MTy=[−5−1]
The normal equations row reduce as: [10−502−1]→[10−501−1/2]\left[\begin{array}{rr|r}1&0&-5\\0&2&-1\end{array}\right]\rightarrow \left[\begin{array}{rr|r}1&0&-5\\0&1&-1/2\end{array}\right][1002−5−1]→[1001−5−1/2] , so the desired approximating function is f(x)=−5sin(x)−(1/2)cos(x)f(x)=-5\sin(x)-(1/2)\cos(x)f(x)=−5sin(x)−(1/2)cos(x) .
Unlock full course notes by signing up
Practice Question: Least Squares for Polynomials
Find the cubic polynomial which best fits the data points (−2,−1),(−1,1),(0,0),(1,−2),(2,3)(-2,-1),(-1,1),(0,0),(1,-2),(2,3)(−2,−1),(−1,1),(0,0),(1,−2),(2,3) in the least squares sense.
Least Squares for Mix of Quadratic and Linear Functions
Find a least squares approximation of form a+bx+cx2+dya+bx+cx^2+dya+bx+cx2+dy for the following data:
x‾y‾result‾11112−121−3222011\begin{array}{r|r|r}\underline{x}&\underline{y}&\underline{result}\\1&1&1\\1&2&-1\\2&1&-3\\2&2&2\\0&1&1\end{array}x11220y12121result1−1−321
Least Squares
Find a function of the form a0+a1x+a3x3a_0+a_1x+a_3x^3a0+a1x+a3x3 (note there is no squared term) which is a best approximation in the sense of least squares to the following data points: (0,1),(−1,1),(1,2),(−2,1)(0,1),(-1,1),(1,2),(-2,1)(0,1),(−1,1),(1,2),(−2,1) .
19.4F_133_8.2_Mock_F1_$\tkco{eg2}$_$\key{Final}$_Builder_$\tkcth{8.2.}\tkcf{2}$_
Show that, in the case that the matrix A‾\AA is invertible, the least squares solution corresponding to the system:
is the same as the solution to the system itself.
Practice: Least Squares Approximation
Find the cubic polynomial which best fits the data points (−2,−1),(−1,1),(0,0),(1,−2),(2,3)(-2,-1),(-1,1),(0,0),(1,-2),(2,3)(−2,−1),(−1,1),(0,0),(1,−2),(2,3).
Example: Least Squares for Linear Functions
Find the equation of the line that comes as close as possible, in the least squares sense, to passing through the points: (0,1),(2,3),(3,4),(4,7)(0,1),(2,3),(3,4),(4,7)(0,1),(2,3),(3,4),(4,7) .
Find the equation of the line that comes as close as possible to passing through the points: (0,1),(2,3),(3,4),(4,7)(0,1),(2,3),(3,4),(4,7)(0,1),(2,3),(3,4),(4,7).
Example: Least Squares for Polynomials
Find the equation of a quadratic polynomial that comes as close as possible to passing through the points: (1,2),(1,3),(2,3)(1,2),(1,3),(2,3)(1,2),(1,3),(2,3).