When approximating an odd function with period $2\pi$ by a Fourier-Sine-Series with $m$ terms, it has the error $$E_m=\int_{-\pi}^\pi \left[f(x)-\sum_{n=1}^m b_n \sin(nx)\right]^2 dx$$
Now I have to find the $b_n$'s which minimize this error. I'm not really sure how to do that (i.e. differentiating $E_m$ with respect to $b_n$). So any advice or hint is very appreciated!
Thank you!
Let $f(x)=\Sigma {a_n\sin(nx)}$ the Fourier expansion of $f$ (which we assume to be integrable for the problem to make sense), so $a_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\sin(nx)dx$ .
Using the orthogonality of $\sin(nx)$ on $[-\pi,\pi]$, we immediately get that $E_m=\sum_{n=1}^{m}{(a_n-b_n)^2}+\sum_{n>m}{a_n^2}$, so in particular $E_m$ is finite if and only if $f \in L^2$ and then $E_m$ is minimal if and only if $b_n=a_n, n=1,...m$, so $b_n$ must be the Fourier coefficients of $f$ obtained as above
Edit to prove the result by differentiation as requested by OP:
Taking partial derivatives w.r. $b_n$ and noting that $E_m$ is quadratic in $b_n$ with no integration w.r. to $b_n$ as variables, so no issues with exchanging derivatives and integrals (we could first take $b_n$ outside the integral, but that complicates stuff unnecessarily);
$\frac{\partial E_m}{\partial b_n}= 2\int_{-\pi}^{\pi}(-\sin(nx))(f(x)-\sum_{k=1}^{m}b_k\sin(kx))dx=2\pi (-a_n+b_n)$ by the above defintion of $a_n$ and since by the orthogonality of $\sin(kx)$ on $[-\pi,\pi]$ all the integrals $\int_{-\pi}^{\pi}\sin(kx)\sin(nx)dx$ cancel unless $k=n$ when they are obviously $\pi$.
So $\frac{\partial E_m}{\partial b_n}=0$ iff $b_n=a_n, n=1,..m$ and this gives the required result that the only possible finite extremum is at $b_n=a_n, n=1,...m$ and then noticing that $E_m$ is non-negative and clearly unbounded at infinity in the $b's$, we get that $b_n=a_n$ must be a minimum.