Example: Least Squares for non-Polynomials

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

Example: Least Squares for non-Polynomials

Find the function of form c1sin⁡(x)+c2cos⁡(x)c_1\sin(x)+c_2\cos(x) which best fits the data points (−π,−3),(0,−4),(π/2,−5)(-\pi,-3),(0,-4),(\pi/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]


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] , so the desired approximating function is f(x)=−5sin⁡(x)−(1/2)cos⁡(x)f(x)=-5\sin(x)-(1/2)\cos(x) .


Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Least Squares Approximation Questions: