I am interested in Fourier series with a non-uniformly weighted error norm. What I mean by this is that the usual Fourier series of a periodic function is a minimizer of the mean squared error: $$ J_N = \int_{0}^{2\pi} \left| f(x) - \tilde{f}_N (x) \right|^2 w(x) dx $$ where $w(x) = 1$, $f$ is the original function and $\tilde{f}$ is its Fourier series truncated to the lowest $N$ terms in frequency. I vaguely recall from analysis that the Fourier series is the unique minimizer in some sense and under certain conditions (in what sense and under what conditions?). I'm interested in the case when $w(x)$ is not a constant; is there a way to compute the Fourier series coefficients in such a case? What can be said about convergence? If this problem has been studied before, I have no idea what to search for.
Edit: By $\tilde{f}_N$ I mean the truncated Fourier series: $$ \tilde{f}_N = \sum_{k=-N}^N a_k e^{i kx} $$ where $a_k$ are just the Fourier series coefficients of $f$: $$ a_k = \int_0^{2\pi} f(x) e^{-ikx} dx $$ I am looking for a "solution" that has the same form as $\tilde{f}_N$ except with different coefficients (say, $b_k$ instead of $a_k$) that minimizes the weighted mean square error for a given $N$. I would like a way to compute $b_k$.
You operate within the weighted Lebesgue space $L^2_w$, within which resides the $(N+1)$-dimensional subspace $M$ spanned by $\{e^{ikx} : |k|\le N\}$. The function $\widetilde {f_N}$ that you want is the orthogonal projection of $f$ onto $M$. This means you are looking for coefficients $c_k$ such that $$\left< \sum_{k=-N}^N c_k e^{ikx} , e^{ikx} \right> = \langle {f}, e^{ikx} \rangle,\quad |k|\le N \tag{2} $$ This is a linear system for $c_k$. Its matrix is the Gramian matrix of $e^{ikx}$, and as such is positive definite. Use any linear solver that takes advantage of this structure.