Challenging series of a fraction with a cosine I am not sure how to determine the following function explicitly:
$$f(x)=\sum_{k=1}^{+\infty} \frac{(-1)^k}{(\pi k)^2}\cos(\pi k x) $$
when $-1<x<1$.
I have tried to take the derivative of this function to deal with a simpler expression, but it is quite challenging.
Do you have any idea on how to approach this? Thank you!
 A: Hint
The Fourier series of $f(\theta) = \theta^2$ defined on $(-\pi, \pi)$ is
$$\frac{\pi^2}{3} + 4 \sum_{k=1}^\infty \frac{(-1)^k}{k^2} \cos k \theta$$
A: If you don't want to use Fourier Series, but are happy to use the well-known variation on the Basel Problem, namely that $$\sum_{k=1}^\infty\frac{(-1)^k}{k^2}=-\frac{\pi^2}{12},$$
Then consider that $$f''(x)=\sum_{k=1}^\infty(-1)^{k+1}\cos(\pi kx)$$
$$=Re\left(\sum_{k=1}^\infty(-1)^{k+1}e^{i\pi kx}\right)$$
$$=-Re\left(\sum_{k=1}^\infty(-e^{i\pi x})^k\right)$$
$$=Re\left(\frac{e^{i\pi x}}{1+e^{i\pi x}}\right)$$
$$=Re\left(\frac{e^{i\pi x}}{1+e^{i\pi x}}\times\frac{1+e^{-i\pi x}}{1+e^{-i\pi x}}\right)$$
$$=Re\left(\frac{e^{i\pi x}+1}{2+2\cos\pi x}\right)=\frac12$$
Hence $$f(x) =\frac14x^2+ax+b$$
And $$f'(x)=\frac12x+a$$
Therefore $$f'(0)=a=0$$ since all the terms in the series are zero, and $$f(0)=b =\frac{1}{\pi^2}\sum_{k=1}^\infty\frac{(-1)^k}{k^2}=-\frac{1}{12}$$
Hence, $$f(x)=\frac14x^2-\frac{1}{12}$$
A: Let's take the following heuristic argument.  There are perhaps ways to prove that the guesses we make are necessary. For instance, since the coefficients on the right-hand side decay as $1/n^2$, the series converges uniformly to $f(x)$, and this for instance justifies the use of the formula for the Fourier coefficients below, because that allows us to switch the integral and the infinite sum.  But that's as far as I'll go with that (perhaps someone can fill in this rigorous details if it's possible).
We assume (without really knowing; our assumption will be justified at the end) that $f$ is as many times differentiable as is necessary. The series for $f(x)$ is a Fourier series, and so we know that the coefficients can be computed as
$$
\frac{(-1)^k}{(\pi k)^2}=\int_{-1}^1\cos(\pi k x)f(x)dx.
$$
Integrating by parts three times yields
\begin{align}
\frac{(-1)^k}{(\pi k)^2}
&=\frac{1}{(\pi k)^3}\int_{-1}^1\sin(\pi k x)f^{(3)}(x)dx
+\frac{(-1)^k}{(\pi k)^2}(f'(1)-f'(-1)).
\end{align}
Staring at this lovingly, we can see that we can automatically satisfy this equation for all $k$ if we guess that
$$
f^{(3)}(x)=0,
$$
and
$$
f'(1)-f'(-1)=1,
$$
and this is satisfied by the function
$$
\tilde{f}(x)=\frac{1}{4}x^2+bx +c.
$$
To get $c$, it is enough to evaluate the Fourier coefficient for $k=0$. To get $b$, we note that $f$ must be even, since it is a sum of cosines, and so $b=0$.
