Evaluating $\int_{-1/2}^{1} \cos^{-1} \frac{1-x^2}{1+x^2} dx$ Let us do the integration by parts  $$I=\int_{-1/2}^{1} ~\cos^{-1} \frac{1-x^2}{1+x^2}. 1~ dx =\left.x \cos^{-1} \frac{1-x^2}{1+x^2}\right|_{-1/2}^{1}-\int_{-1/2}^{1} \frac{2x}{1+x^2} dx$$ $$=\frac{\pi}{2}+\frac{1}{2}\cos^{-1} \frac{3}{5}-\left .\ln(1+x^2)\right|_{-1/2}^{1}=\frac{\pi}{2}+\frac{1}{2}\cos^{-1} \frac{3}{5}-\ln\frac{8}{5}.$$
The question is whether something is amiss here and whether the answer is right.
EDit
The correct answer is $$I=\frac{\pi}{2}+\frac{1}{2}\cos^{-1} \frac{3}{5}-\ln\frac{5}{2}.$$
 A: Set $\tan^{-1}x=y, -\dfrac\pi2<y<\dfrac\pi2\iff-\pi<2y\le\pi $
$$\cos^{-1}\dfrac{1-x^2}{1+x^2}=\cos^{-1}(\cos2y)=\begin{cases}2y &\mbox{if }0\le2y\le\pi\iff x\ge0 \\
-2y & \mbox{if } x<0\end{cases} $$
$$\implies\int_{-1/2}^1\cos^{-1}\dfrac{1-x^2}{1+x^2}dx=-2\int_{-1/2}^0\tan^{-1}x\ dx+2\int_0^1\tan^{-1}x\ dx$$
Now integrate by parts $$\displaystyle\int\tan^{-1}x\ dx=\tan^{-1}x\int\ dx-\int\left(\dfrac{d(\tan^{-1}x)}{dx}\int\ dx\right)dx$$
A: The error is in the sign that is different for $x\leq0$ and $x\geq0:$
$$
x \frac{d}{dx}\cos^{-1}\frac{1-x^2}{1+x^2}=
\left\{
\begin{alignedat}{2}
-\dfrac{2x}{1+x^2}\quad & -&&1\leq x\leq 0 \\
+\dfrac{2x}{1+x^2}\quad &  &&0\leq x\leq 1 
\end{alignedat}
\right.
$$
so that
\begin{align}
I
  &=\int_{-1/2}^{1}\cos^{-1}\left(\frac{1-x^2}{1+x^2}\right)dx =\\
  &=\left.x\cos^{-1}\left(\frac{1-x^2}{1+x^2}\right)\right|_{-1/2}^{1}+\int_{-1/2}^{0} \frac{2x}{1+x^2} dx-\int_{0}^{1} \frac{2x}{1+x^2} dx=\\
  &=\frac{\pi}{2}+\frac{1}{2}\cos^{-1}\left(\frac{3}{5}\right)-\ln\frac{5}{4}-\ln 2\\
  &=\frac{\pi}{2}+\frac{1}{2}\cos^{-1}\left(\frac{3}{5}\right)-\ln\frac{5}{2}.
\end{align}
