I was analyzing this integral which prompted me to ask this question: \begin{aligned} & \int_0^{2 \pi} \cos ^{-1}\left(\frac{1-\tan ^2 \frac{x}{2}}{1+\tan ^2 \frac{x}{2}}\right) d x \\ & \int_0^{2 \pi} \cos ^{-1}(\cos x) d x \\ & \int_0^{2 \pi} x d x=\left(\frac{x^2}{2}\right)_0^{2 \pi}=\frac{1}{2}\left(4 \pi^{-2}\right)=2 \pi^2 \\ & \int_0^{2 \pi} \cos ^{-1}(\cos (2 \pi-x))= 2*\int_0^\pi \cos ^{-1}(\cos x)=2 \int_0^\pi x=\pi^2 \end{aligned}
Why I'm I getting 2 different answers when used with (3rd step) and without (final step) the property? I'm neither sure whether it is due to some inverse trignometric property or due to my lack of understanding of definite integral properties.
Could someone please explain. Thanks