<s>[INST] Solving definite integral $\int_{0}^{1} \tan^{-1}(1-1/x)dx$ $$\int_{0}^{1} \tan^{-1}\left(1-\frac1x\right)dx$$
Here's what I have done so far. (the answer is given as $-\pi/4$)
Let
$$
I = \int_{0}^{1}\tan^{-1}\left(1-\frac1x\right)dx = \int_{0}^{1}\tan^{-1}\left(\frac{x-1}x\right)dx.
$$
Since, $\int_{0}^{1} f(x)dx = \int_{0}^{1} f(1-x)dx$ one has\begin{align}
I &= \int_{0}^{1}\tan^{-1}\left(1-\frac1{1-x}\right)dx\\
& = \int_{0}^{1}\tan^{-1}\left(\frac x{x-1}\right)dx\\
& = \int_{0}^{1}\frac\pi2-\cot^{-1}\left(\frac x{x-1}\right)dx\\
& = \int_{0}^{1}\frac\pi2-\tan^{-1}\left(\frac{x-1}x\right)dx\\
& = \frac\pi2 - I,
\end{align}
Hence, $I = \dfrac\pi4$. The given answer is $-\dfrac\pi4$. Where have I gone wrong?
 [/INST] $$\begin{align*}
\int_0^1 \arctan\left(1 - \frac1x\right) \, dx &= \int_{-\infty}^0 \frac{\arctan(x)}{(1-x)^2} \, dx & (1) \\[1ex]
&= -\int_{-\infty}^0 \frac{dx}{(1+x^2)(1-x)} & (2) \\[1ex]
&= -\int_0^\infty \frac{dx}{(1+x^2)(1+x)} & (3) \\[1ex]
&= -\frac12 \int_0^\infty \left(\frac1{1+x} - \frac{x}{1+x^2} + \frac1{1+x^2}\right) \, dx & (4) \\[1ex]
&= \frac12 \lim_{x\to-\infty} \left(\ln\left|\frac{1+x}{\sqrt{1+x^2}}\right| + \arctan(x)\right) & (5) \\[1ex]
&= \boxed{-\frac\pi4}
\end{align*}$$
$\begin{array}{cl}
(1) & \text{substitute }x\mapsto\frac1{1-x} \\
(2) & \text{integrate by parts} \\
(3) & \text{substitute }x\mapsto-x \\
(4) & \text{expand into partial fractions} \\
(5) & \text{apply the fundamental theorem of calculus}
\end{array}$
</s>