(This question comes from this video)
Imagine we are trying to solve the integral :
$$I=\int_{0}^{\pi/2} \ln(2\cos x)\,dx$$ This integral is defined on the real numbers. However, if I decide to use eulers complex cosine formula ($\cos \theta = \frac{e^{i\theta}+e^{-i\theta}}{2}$), I can reduce the integral to this (this is shown in the video) :
$$ I = \frac{i\pi^2}{8} - i( 1+\frac{1}{3^2}+\frac{1}{5^2}+\frac{1}{7^2}+\frac{1}{9^2}+\cdots)$$
As you can the the result found this way is a pure imaginary number. In the video, it is then explained that since the integral is defined on the real numbers, therefor the complex result is simply a "residue" of the calculations. My question is, is this reasoning valid ? If not, what could bring us to the same result, that $I = 0$ (I doubt the youtube video would assume something wrong)
I turns out that the result is correct and saying that the result is equal to zero means that $1+\frac{1}{3^2}+\frac{1}{5^2}+\frac{1}{7^2}+\frac{1}{9^2}+\cdots = \frac{\pi^2}{8}$. We can the continue and use this result to show that $\sum_{k=1}^\infty \frac{1}{k^2} = \frac{\pi^2}{6}$.