I have three points $(t,f(t))$: $(-3,1)$, $(0,5+\sqrt{2})$ ,$(1,7)$ and want to solve for $a$ and $b$ in the following functions, such that the solution is the best approximation to the overdetermined system.
$$f(t)=at+b\cos\left(\frac{\pi t}{4}\right)+5$$
Now I want to set up the Matrix $A$ such that I can solve for that solution using the normal equation $A^{t}Ax=A^{t}b$.
But I'm having a little trouble setting the matrix up such that I get a system $Ax=b$. I can calculate the values $\cos\left(\frac{\pi t}{4}\right)$ but how do I get the $+5$ into the system:
$$A\begin{pmatrix}a\\b\end{pmatrix}=y$$
It's probably a very simple fix...
Pick a set of $t$'s: $t_1 = -1, t_2 = 0, t_3=1$ and evaluate $\cos (\pi t_i/4) = c_i$, let $f_1 = 1, f_2 = 5\sqrt{2}, f_3=4$ and form the matrix equation $$ \begin{pmatrix} t_1 & c_1 \\ t_2 & c_2 \\ t_3 & c_3 \end{pmatrix} \begin{pmatrix} a \\ b \end{pmatrix} = \begin{pmatrix} f_1 - 5 \\ f_2 -5 \\ f_3 -5 \end{pmatrix} $$ and solve it the way you propose...