Show that $\sum_{n=1}^{\infty} \frac{(-1)^{n}}{n^{2}}\cos nx=\frac{1}{12}(3x^{2}-\pi^2)$ for $-\pi \leq x \leq \pi $ How do we show that for $-\pi \leq x \leq \pi $,
$$\sum_{n=1}^{\infty} \frac{(-1)^{n}}{n^{2}}\cos nx=\frac{1}{12}(3x^{2}-\pi^2)$$
I know that without $(-1)^{n}$ term, the series converges to $\frac{x^{2}}{4}-\frac{\pi x }{2}+\frac{\pi^{2}}{6}$ for $x$ in $[0,2\pi]$.  But I'm not sure how to find the sum if there is a $(-1)^{n}$ term there.
Thank you for your help!
 A: You could use the Fourier Series of $f(x)=\frac1{12}(3x^2-\pi^2)$ in $[-\pi,\pi].$
$$f(x)=\frac{a_0}2+\sum_{n=1}^\infty[a_n\cos(nx)+b_n\sin(nx)]$$where$$a_{n\ge0}=\frac1\pi\int_{-\pi}^\pi f(x)\cos(nx)~dx=\frac1{12\pi}\int_{-\pi}^\pi(3x^2-\pi^2)\cos(nx)~dx$$For $n=0$,$$a_0=\frac1{6\pi}[x^3-\pi^2x]_0^\pi=0$$For $n\ge1$,
$a_n=\frac1{12\pi}\left\{\left[(3x^2-\pi^2)\int\cos(nx)~dx\right]_{-\pi}^\pi-6\int_{-\pi}^\pi x\int\cos(nx)~dx~dx\right\}\\=-\frac1{n\pi}\int_0^\pi x\sin(nx)~dx=-\frac1{n\pi}\left\{\left[x\int\sin(nx)~dx\right]^\pi_0-\int_0^\pi\int\sin(nx)~dx\right\}\\=\frac{\cos(n\pi)}{n^2}$
and$$b_{n\ge1}=\frac1\pi\int_{-\pi}^\pi f(x)\sin(nx)~dx=0~\forall n.$$
Since $f(x)$ is continuous in the given domain, the Fourier series$$\sum_{n=1}^\infty\frac{(-1)^n}{n^2}\cos(nx)$$will converge to $f(x)$ for each point due to Dirichlet conditions.
A: Denote $f(x)= \sum_{n=1}^{\infty} \frac{(-1)^{n}}{n^{2}}\cos nx$. Then,
$f(0)= \sum_{n=1}^{\infty} \frac{(-1)^{n}}{n^{2}}=-\frac{\pi^2}{12} $
\begin{align}
f’(x) & = -\sum_{n=1}^{\infty} \frac{(-1)^{n}}{n}\sin nx
=\frac1{2i}\sum_{n=1}^{\infty}(-1)^{n+1}\frac{e^{ixn }-e^{-ixn }}{n}\\
&=\frac1{2i}[\ln(1+e^{ix })-\ln (1+e^{-ix })]
=\frac1{2i}\ln e^{ix}
=\frac{x}{2}\\
\end{align}
Thus
$$\sum_{n=1}^{\infty} \frac{(-1)^{n}}{n^{2}}\cos nx
= f(0) + \int_0^x f’(t)dt = \frac{1}{12}(3x^{2}-\pi^2)$$
A: Let $f(x;\lambda)$ be given by the series
$$f(x;\lambda)=-\sum_{n=1}^\infty \lambda^n e^{inx}\tag1$$
for $|\lambda|<1$.

Summing the geometric series in $(1)$ we find that for $|\lambda|<1$
$$f(x;\lambda)=\frac{\lambda e^{ix}}{\lambda e^{ix}-1}\tag2$$

Exploiting the uniform convergence of $\sum_{n=1}^\infty \lambda^n e^{inx}$ for $\lambda \in [-1+\delta, 1-\delta]$, $\delta>0$, integrating $f(x;\lambda)$ in $(1)$, taking the real part reveals
$$\text{Re}\left(\int_0^x f(t;\lambda)\,dt\right)=-\sum_{n=1}^\infty \frac{\lambda^n\sin(nx)}{n}\tag3$$

Then, exploiting the uniform convergence of $\sum_{n=1}^\infty \frac{\lambda^n\sin(nx)}{n}$ for $\lambda \in [-1,1]$ and for $x\in [\nu,2\pi-\nu]$, $\nu>0$, we let $\lambda \to -1^+$  in $(3)$ to find
$$\begin{align}
\lim_{\lambda\to 1^-}\text{Re}\left(\int_{0}^x f(t;\lambda)\,dt\right)&=-\sum_{n=1}^\infty \frac{(-1)^n\sin(nx)}{n}\tag4
\end{align}$$

Going back to $(2)$, we integrate $f(x;\lambda)$, take the real part, and let $\lambda\to -1^+$ to find
$$\lim_{\lambda\to -1^-}\text{Re}\left(\int_{0}^x f(t;\lambda)\,dt\right)=\frac x2\tag5$$

Integrating $(4)$ and $(5)$ once more and using $\sum_{n=1}^\infty \frac1{n^2}=\frac{\pi^2}{12}$ yields
$$\sum_{n=1}^\infty \frac{(-1)^n \cos(nx)}{n^2}=\frac{x^2}{4}-\frac{\pi^2}{12}$$
as was to be shown!
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
\left.\sum_{n = 1}^{\infty}{\pars{-1}^{n} \over n^{2}}\cos\pars{nx}
\,\right\vert_{\ds{\ -\pi\ \leq\ x\ \leq\ \pi}} & =
\sum_{n = 1}^{\infty}{\cos\pars{n\bracks{x + \pi}} \over n^{2}} =
\Re\sum_{n = 1}^{\infty}{\bracks{\expo{\ic\pars{x + \pi}}}^{n} \over n^{2}}
\\[5mm] & =
\Re\mrm{Li}_{2}\pars{\expo{\ic\bracks{x + \pi}}}
\end{align}
where $\ds{\mrm{Li}_{s}}$ is a
Polylogarithm.
Then,
\begin{align}
&\left.\sum_{n = 1}^{\infty}{\pars{-1}^{n} \over n^{2}}\cos\pars{nx}
\,\right\vert_{\ds{\ -\pi\ \leq\ x\ \leq\ \pi}}
\\[5mm] = &\
{1 \over 2}\bracks{%
\mrm{Li}_{2}\pars{\exp\pars{2\pi\,{x + \pi \over 2\pi}\ic}} +
\mrm{Li}_{2}\pars{\exp\pars{-2\pi\,{x + \pi\over 2\pi}\ic}}}
\\[5mm] & =
{1 \over 2}\bracks{-\,{\pars{2\pi\ic}^{2} \over 2!}
\,\mrm{B}_{2}\pars{x + \pi\over 2\pi}}
\end{align}
Here, I used
Jonqui$\grave{\mrm{e}}$re Inversion Formula
and $\ds{\mrm{B}_{n}}$ is a Bernoulli Polynomial. For instance, $\ds{\mrm{B}_{2}\pars{x} = x^{2} - x + 1/6}$.
Therefore,
\begin{align}
\left.\sum_{n = 1}^{\infty}{\pars{-1}^{n} \over n^{2}}\cos\pars{nx}
\,\right\vert_{\ds{\ -\pi\ \leq\ x\ \leq\ \pi}} & =
\pi^{2}\bracks{\pars{x  + \pi \over 2\pi}^{2} - {x + \pi \over 2\pi} +
{1 \over 6}}
\\[5mm] & =
\bbx{{1 \over 12}\pars{3x^{2} - \pi^{2}}}
\\[5mm] &
\end{align}
