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!

  • 1
    $\begingroup$ @PeterForeman that's true, but I guess the major problem is determine rhs by lhs $\endgroup$
    – openspace
    Jul 27, 2020 at 18:47
  • $\begingroup$ Sometimes it works: let $S$ be rhs. Now differentiate it. Maybe its easier to check derivative. Or second derivative. $\endgroup$
    – openspace
    Jul 27, 2020 at 18:51
  • 3
    $\begingroup$ Hint: Replace $x$ by $x-\pi$ in the LHS and use the addition formulae. You should immediately see the form of your answer without the $(-1)^n$. Also the domain changes correspondingly. $\endgroup$ Jul 27, 2020 at 18:52
  • $\begingroup$ split the sum into even /odd n's $\endgroup$
    – G Cab
    Jul 27, 2020 at 19:00

4 Answers 4


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.


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}


$$\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)$$


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!


$\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}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.