Question: Which even function $f(x)$ satisfies $$\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos(nx)~dx=\frac{1}{n}? $$ Alternatively, which even function $f(x)$ satisfies $$\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos(nx)~dx=(-1)^n\frac{1}{n}? $$
Background: I've been experimenting with Fourier series recently and I found that $$x=\sum_{n=1}^\infty(-1)^{n+1}\frac{2}{n}\sin(nx),$$ or equivalently $$\frac{1}{\pi}\int_{-\pi}^{\pi}x\sin (nx) dx=(-1)^{n+1}\frac{2}{n}.$$ I was just wondering if there was an even function that would have similar coefficients in its Fourier series expansion: more precisely, if I could find an even function satisfying the conditions in my question.
Unfortunately, I cannot show any attempts here since I can't see any way of attacking this problem other than by trying out different even functions and finding their Fourier coefficients, which has so far been unsuccessful.
Thank you very much for your help.
Thanks to the comment of @AndreaS. I have now managed to answer my question.
Using the fact that $$f(x)=\frac{a_0}{2}+\sum_{n=1}^\infty(a_n\cos(nx)+b_n\sin(nx))$$ where $$ a_k=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos(kx)dx,~~~b_k=\frac{1}{\pi}\int_{-\pi}^\pi f(x)\sin(nx)dx$$ it's clear that the function satisfying the given conditions is of the form $$f(x)=C+\sum_{n=1}^\infty\frac{\cos(nx)}{n}$$ where $C$ is some constant of my choosing. I'll set $C=0$. Hence, $$\begin{align} f(x)&=\sum_{n=1}^\infty\frac{\cos(nx)}{n}\\ &=\frac{1}{2}\sum_{n=1}^\infty\frac{e^{nix}+e^{-nix}}{n}\\ &=-\frac{1}{2}(\log(1-e^{ix})+\log(1-e^{-ix}))\\ &=-\frac{1}{2}\log(2-2\cos x)\\ &=-\log\left\lvert2\sin\frac{x}{2}\right\rvert. \end{align}$$