-2
$\begingroup$

Solutions which use matrices would be greatly appreciated.

Find the trigonometric function of the form $f(t) = c_0+c_1\sin(t)+c_2\cos(t)$ that best fits the data points $(0,0), (1,1), (2,2), (3,3)$ using least squares.

My question is, would I go about this in the same way as I would if I was using a least squares approach to fit 4 sets of coordinates to a quadratic line? Or does the trigonometry result in me having to go about this question in a different way? If so, how?

  • 0
    your first line is rudely demanding, your tags are inaccurate, you made no attempt on your own, and you did not attempt to use any proper readable formatting. this will not help you get good responses.2017-02-04
  • 0
    @TheCount hi, thank you for your comments. I hope i have made appropriate changes.2017-02-04
  • 0
    Looks similar to https://math.stackexchange.com/questions/2123895/solving-a-least-square-problem.2017-03-10

1 Answers 1

0

You have a trial function and let's generalize the data to the sequence $\left\{ t_{k}, f_{k} \right\}_{k=1}^{m}$. The linear system takes the form $$ \begin{align} \mathbf{A} \alpha &= f \\[3pt] % \left[ \begin{array}{ccc} \mathbf{1} & s & c \end{array} \right] % \left[ \begin{array}{c} \alpha \end{array} \right] % &= \left[ \begin{array}{c} f \end{array} \right] % \\[5pt] % \left[ \begin{array}{ccc} 1 & \sin t_{1} & \cos t_{1} \\ 1 & \sin t_{2} & \cos t_{2} \\ \vdots & \vdots & \vdots \\ 1 & \sin t_{m} & \cos t_{m} \end{array} \right] % \left[ \begin{array}{c} \alpha_{0} \\ \alpha_{1} \\ \alpha_{2} \end{array} \right] % &= % \left[ \begin{array}{c} f_{1} \\ f_{2} \\ \vdots \\ f_{m} \end{array} \right]. \end{align} $$

Set up the normal equations: $$ \begin{align} \mathbf{A}^{*} \mathbf{A} \alpha &= \mathbf{A}^{*} f \\[3pt] % \left[ \begin{array}{ccc} \mathbf{1} \cdot \mathbf{1} & \mathbf{1} \cdot s & \mathbf{1} \cdot c \\ s \cdot \mathbf{1} & s \cdot s & s \cdot c \\ c \cdot \mathbf{1} & c \cdot s & c \cdot c \end{array} \right] % \left[ \begin{array}{c} \alpha_{0} \\ \alpha_{1} \\ \alpha_{2} \end{array} \right] % &= % \left[ \begin{array}{c} \mathbf{1} \cdot f \\ s \cdot f \\ c \cdot f \end{array} \right]. & \end{align} $$

Solve the normal equations: $$ \begin{align} \alpha &= \left( \mathbf{A}^{*} \mathbf{A} \right)^{-1} \mathbf{A}^{*} f \\[3pt] % \left[ \begin{array}{c} \alpha_{0} \\ \alpha_{1} \\ \alpha_{2} \end{array} \right] % &= % \left[ \begin{array}{ccc} \mathbf{1} \cdot \mathbf{1} & \mathbf{1} \cdot s & \mathbf{1} \cdot c \\ s \cdot \mathbf{1} & s \cdot s & s \cdot c \\ c \cdot \mathbf{1} & c \cdot s & c \cdot c \end{array} \right]^{-1} % \left[ \begin{array}{c} \mathbf{1} \cdot f \\ s \cdot f \\ c \cdot f \end{array} \right]. & \end{align} $$