TITLE: Why is $ \ln\left(\cos{\left(\frac{\pi x}{2}\right)}\right) \neq \sum_{n=0}^{\infty} \ln(\,(2n+1)^{2}-x^2) $
QUESTION [5 upvotes]: Known Definition :
$$ \tan{\left(\frac{\pi x}{2}\right)} = \frac{4}{\pi} \sum_{n=0}^{\infty} \frac{x}{(2n+1)^{2}-x^2} $$
I integrate both sides with respect to $x$ to obtain :
$$ \ln\left(\cos{\left(\frac{\pi x}{2}\right)}\right)= \sum_{n=0}^{\infty} \ln(\,(2n+1)^{2}-x^2) $$
However, this appears to NOT be true due to the series on the RHS diverging, why does this occur? and where am I making the mistake?
Thank you kindly for your help and time.

REPLY [3 votes]: The mistake is in choosing the antiderivatives that makes the RHS diverges.  Instead, do a definite integral of both sides with
$$
\int_0^x\frac{\xi}{(2n+1)^2-\xi^2}\,\mathrm{d}\xi=\log(2n+1)-\frac12\log((2n+1)^2-x^2)
$$
for each of your summand, and get
$$
\log\cos\left(\frac{\pi x}2\right)=\sum_{n=0}^\infty\log\left(1-\frac{x^2}{(2n+1)^2}\right),\quad \lvert x\rvert<1.
$$