# How to justify interchange of summation and integral with $f_n(x)=x^2 \cos(2nx)/n$ on $[0, \pi/2]\times \mathbb{N}$?

I am trying to compute $$\int_0^{\pi/2}\sum_{n=1}^\infty \frac{x^2\cos(2nx)}{n}\,dx.$$ To do so, I would like to interchange integral and sum, but I am having trouble justifying the validity of this exchange. By Fubini-Tonelli, we just need to check that $$\int_0^{\pi/2}\sum_{n=1}^\infty \frac{x^2|\cos(2nx)|}{n}\,dx$$ is well-defined classically (the order is irrelevant to existence). However, I am not sure how to control or estimate this expression. I thought of re-writing the magnitude of $$\cos(2nx)$$ as $$\frac{1}{\sqrt{2}}(1+\cos(4nx)^{1/2}$$ but wasn't able to make much progress.

• The map $g:\theta\mapsto\sum^\infty_{n=1}\frac{\cos 2n x}{n}$ is in $L_2([0,\pi])$ by Bessel's inequality. Hence $g\mathbb{1}_{[0,\pi/2]}$ is also in $L^2[0,\pi]$. As $S_N=\sum^N_{k=1}\frac{\cos 2nx}{n}$ converges to $g$ in $L_2$ (Parseval's theorem) $S_N\mathbb{1}_{[0,\pi/2]}$ converges to $g\mathbb{1}_{[0,\pi/2]}$ in $L_2[0,\pi]$. The conclusion follows from continuity of the dot product. Aug 29, 2021 at 18:18

As you pointed out, we can try to apply Fubini's theorems. The requirement is $$\sum_{n=1}^\infty\int_0^{\pi/2}\frac{x^2\,\lvert{\cos(2nx)}\rvert}{n}\,\mathrm dx<\infty.\tag{\star}$$ If this is the case, then Fubini's theorems give us that:

1. the sequence $$n\mapsto\int_0^{\pi/2}\frac{x^2\cos(2nx)}n\,\mathrm dx$$ is summable;
2. the function $$x\mapsto\sum_{n=1}^\infty\frac{x^2\cos(2nx)}n$$ is defined for almost every $$x\in(0,\frac\pi2)$$ and is integrable;
3. further, $$\sum_{n=1}^\infty\left(\int_0^{\pi/2}\frac{x^2\cos(2nx)}n\,\mathrm dx\right) =\int_0^{\pi/2}\left(\sum_{n=1}^\infty\frac{x^2\cos(2nx)}n\right)\mathrm dx.\tag{\heartsuit}$$

By introducing the change of variables $$y\gets2nx$$, we compute \begin{align*}\int_0^{\pi/2}\frac{x^2\,\lvert{\cos(2nx)}\rvert}n\,\mathrm dx&=\frac1{8n^4}\int_0^{n\pi}y^2\,\lvert{\cos y}\rvert\,\mathrm dy\\[.4em]&\ge\frac1{8n^4}\sum_{k=0}^{n-1}\int_{k\pi}^{k\pi+\frac\pi4}y^2\,\lvert{\cos y}\rvert\,\mathrm dy\\[.4em]&\ge\frac1{8n^4}\sum_{k=0}^{n-1}\frac\pi4(k\pi)^2\cos\left(\frac\pi4\right)\end{align*} which is unfortunately of order $$n^{-1}$$. Therefore $$(\star)$$ cannot hold as the integral there is not summable.

Nonetheless, we can still establish $$(\heartsuit)$$ as the series $$\Sigma f_n(x)$$ is uniformly convergent on the compact interval $$[0,\frac\pi2]$$. From a classical trigonometric sum (see, e.g., Dirichlet's kernel), we have $$d_n(x):=\sum_{k=1}^n\cos(2kx)=\frac{\sin(nx)\cos((n+1)x)}{\sin(x)}$$ (where the fraction equals $$n$$ for $$x=0$$). Besides, Abel's summation formula gives that $$s_n(x):=\sum_{k=1}^nf_k(x)=x^2\sum_{k=1}^n\frac{d_k(x)-d_{k-1}(x)}k=x^2\sum_{k=1}^{n-1}\frac{d_k(x)}{k(k+1)}+\frac{x^2d_n(x)}n.$$

Now for all $$n>m$$, $$\lvert s_n(x)-s_m(x)\rvert\le\sum_{k=m}^{n-1}\frac{x^2\lvert d_k(x)\rvert}{k(k+1)}+\frac{x^2\lvert d_n(x)\rvert}n+\frac{x^2\lvert d_m(x)\rvert}m.$$ We observe that the sequence $$(x^2d_k(x))_{k\ge1}$$ is uniformly bounded on $$[0,\frac\pi2]$$ because $$\lvert{\cos}\rvert,\lvert{\sin}\rvert\le1$$ and the function $$x\mapsto x^2/{\sin(x)}$$ is bounded there. It easily follows by Cauchy's criterion that $$(s_n)_{n\ge1}$$ is uniformly convergent on $$[0,\frac\pi2]$$. This implies $$(\heartsuit)$$ as $$\left\lvert\int_0^{\pi/2}s_n(x)\,\mathrm dx-\int_0^{\pi/2}s_\infty(x)\,\mathrm dx\right\rvert\le\int_0^{\pi/2}\lvert s_n(x)-s_\infty(x)\rvert\,\mathrm dx\le\frac\pi2\|s_n-s_\infty\|_\infty\xrightarrow[n\to\infty]{}0.$$ (I found that the value of $$\int_0^{\pi/2}s_\infty(x)\,\mathrm dx$$ is $$-3\pi\zeta(3)/16$$.)

Let $$f_n(x)=\cos(2nx)$$. Then $$f_n$$ satisfies $$-\frac{d^2}{dx^2}f_n=\lambda_n f_n, \;\; \lambda_n=4n^2,\\ f_n'(0)=0,\;\; f_n'(\pi/2)=0.$$ Because of this, the functions $$\{ f_n \}_{n=1}^{\infty}$$ are mutually orthogonal in $$L^2[0,\pi/2]$$. And $$\int_0^{\pi/2} \cos^2(2nx)dx = \frac{1}{2}\int_0^{\pi/2} \cos^2(2nx)+\sin^2(2nx)dx \\ = \frac{1}{2}\int_0^{\pi/2} dx = \frac{\pi}{4}.$$ So the following sum converges in the norm of $$L^2[0,\pi/2]$$: $$\sum_{n=1}^{\infty}\frac{\cos(2nx)}{n}.$$ Because $$x^2\in L^2[0,\pi/2]$$, it follows that $$\int_0^{\pi/2} x^2 \sum_{n=1}^{\infty}\frac{\cos(2nx)}{n}dx = \sum_{n=1}^{\infty}\int_0^{\pi/2}x^2\frac{\cos(2nx)}{n}dx.$$ This is because of continuity of the inner product in $$L^2[0,\pi/2]$$.