One of my questions from my review sheet is:
Let $f(x) = |x| \text{ for } x \in [−\pi, \pi]$.
(a) Find the least squares approximation to $f(x)$ by a trigonometric polynomial of degree $n$.
(b) Let $x_j = −\pi + j(2\pi/8)$. Find the interpolating trigonometric polynomial of $f$ associated to these nodes.
For part a), I solved using fourier analysis. But my question is, is this ok to do when asked for a least squares approximation, or is there some formula to do least squares with trig? By using fourier analysis, I solved for $a_o$, $a_k$, and $b_k$ and got the polynomial $S_n$(x) to be equal to π+ the summation of $((2\cos k\pi)-2)/(\pi*k**2)$. I am not sure if this math is correct, but that is not really my question. I am wondering if using fourier analysis is the correct way to solve a least squares approximation by trig polynomial. I also have no idea how to solve b) and would appreciate a push in the right direction (not the answer!! just how to solve or a starting point)