Evaluate $\int \arctan({\frac{x-2}{x+2}})\,\text dx$ $$
\int \arctan\left({\frac{x-2}{x+2}}\right)\,\text dx
$$
It seems to be solved in just one line:
$$
x \arctan\left({\frac{x-2}{x+2}}\right)-\log|x^2+4|+c
$$
but how?
I have tried with integration by parts (by picturing out $1$ multiplying arctan), but I don't think is the right way.
 A: We have using first integration by parts:
$$
\begin{aligned}
\int \arctan\frac{x-2}{x+2}\; dx
&=
\int x'\cdot\arctan\frac{x-2}{x+2}\; dx
\\
&=
x\arctan\frac{x-2}{x+2}
-
\int x\cdot\underbrace{\left(\arctan\frac{x-2}{x+2}\right)'}_{2/(x^2+4)}\; dx
\\
&=
x\arctan\frac{x-2}{x+2}
-
\int \frac{d(x^2+4)}{x^2+4}\\
&=
x\arctan\frac{x-2}{x+2}
-
\log(x^2+4)+ c\ .
\end{aligned}
$$
A: WLOG $t=\arctan\dfrac x2,x=2\tan t,dx=2\sec^2t\ dt$
$$\dfrac{x-2}{x+2}=\dfrac{\tan t-1}{\tan t+1}=\tan\left(t-\dfrac\pi4\right)$$
Using Inverse trigonometric function identity doubt: $\tan^{-1}x+\tan^{-1}y =-\pi+\tan^{-1}\left(\frac{x+y}{1-xy}\right)$, when $x<0$, $y<0$, and $xy>1$,
$$\arctan\dfrac x2+\arctan(-1)=\begin{cases} \arctan\frac{\dfrac x2-1}{1+\dfrac x2} &\mbox{if } -\dfrac x2<1\\ \pi+\arctan\frac{\dfrac x2-1}{1+\dfrac x2} & \mbox{if } -\dfrac x2>1\\-\dfrac\pi2 & \mbox{if } x=-2\end{cases} $$
Now for $-\dfrac x2<1,$ $$I=\int\arctan\frac{\dfrac x2-1}{1+\dfrac x2} \ dx=2\int\left(t-1\right)\sec^2t\ dt$$
Integrating by parts,
$$I=2t\int\sec^2t\ dt-\int\left(\int\dfrac{d(2t)}{dt}\int\sec^2t\ dt\right)\ dt-2\sec^2t\ dt$$
Can you take it from here?
