An infinite Series Question While reading an old calculus text book the following problem was given as a general exercise.

If the sum of the series $a_{0} + a_{1}x + a_{2} x^{2} + \cdots$ can be expressed in a finite form, then the sum of the series $a_{0}^{2} + a_{1}^{2} x^{2} + a_{2}^{2} x^{4} + \cdots$ can be expressed by a definite integral. Prove this, and hence show that the sum of the squares of the coefficients of the terms of the expansion of $(1 + x)^{n}$, when n is a positive whole number, may be expressed by 
  $$\frac{4^{n+1}}{\pi} \, \int_{0}^{\pi/2} \cos^{2n}\theta \, \cos(n \theta) \, d\theta - 1.$$

Are there methods that are common that can offer an solution to this problem? 
 A: The hidden trick is just the following one:
$$ \forall n,m\in\mathbb{Z},\qquad \int_{0}^{2\pi}e^{ni\theta}e^{-mi\theta}\,d\theta = 2\pi\cdot \delta(n,m).\tag{1}$$
Implementation: assuming that
$$ \sum_{n\geq 0} a_n x^n = f(x),\tag{2} $$
by $(1)$ (i.e. by Parseval's theorem) it follows that:

$$ \sum_{n\geq 0} a_n^2\, x^{2n} = \frac{1}{2\pi}\int_{0}^{2\pi}f(xe^{i\theta})\cdot f(xe^{-i\theta})\,d\theta. \tag{3}$$

Consequence: if $f(x)=(1+x)^n=\sum_{k=0}^{n}\binom{n}{k}x^k$, we have:
$$\sum_{k=0}^{n}\binom{n}{k}^2 = \frac{1}{2\pi}\int_{0}^{2\pi}(1+e^{i\theta})^n (1+e^{-i\theta})^n\,d\theta=\frac{1}{2\pi}\int_{0}^{2\pi}(2+2\cos\theta)^n\,d\theta.\tag{4} $$
Straightforward simplifications lead to your claim.
A: Let
\begin{align}
F(x) &= \sum_{k=0}^{\infty} a_{k} \, x^{k} \\
f(x) &= \sum_{k=0}^{\infty} b_{k} \, x^{k}
\end{align}
then
\begin{align}
\sum_{k=0}^{\infty} a_{k} \, b_{k} \, x^{2k} = \frac{1}{2\pi} \, \int_{0}^{2\pi} [F(x e^{i \theta/2}) + F(x e^{-i \theta/2})] \cdot [f(x e^{i \theta/2}) + f(x e^{-i \theta/2})] \, d\theta - a_{0} b_{0}.
\end{align}
The result of the coefficients follows by setting $F(x) = f(x) = (1+x)^{n}$. 
