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?
 A: By integration by parts, one has
\begin{eqnarray}
\int_0^1 \arctan\left(1 - \frac1x\right) \, dx &=& -\int_0^1 \frac{x}{1+(1-\frac1x)^2}\frac{dx}{x^2}\\
&=& -\int_0^1 \frac{x}{2x^2-2x+1}dx\\
&=& \boxed{-\frac\pi4}
\end{eqnarray}
Update:
\begin{eqnarray}
\int_0^1 \frac{x}{2x^2-2x+1}dx&=&\int_0^1 \frac{2x}{(2x-1)^2+1}dx\\
&=&\int_0^1 \frac{2x-1}{(2x-1)^2+1}dx+\int_0^1 \frac{1}{(2x-1)^2+1}dx\\
&=&\frac{1}{4}\ln[(2x-1)^2+1]+\frac12\arctan(2x-1)\bigg|_0^1 \\
&=&\frac\pi4.
\end{eqnarray}
A: Noticing that
$$
\tan \left[\tan ^{-1}\left(\frac{x-1}{x}\right)+\frac{\pi}{4}\right]=\frac{\frac{x-1}{x}+1}{1-\frac{x-1}{x}}=2 x-1
$$
For $x\in (0,1)$, $$
\tan ^{-1}\left(\frac{x-1}{x}\right)+\frac{\pi}{4}=\tan ^{-1}(2 x-1)
$$
Integrating both sides from $0$ to $1$ yields
$$
\begin{aligned}
\int_{0}^{1} \tan ^{-1}\left(1-\frac{1}{x}\right) d x+\frac{\pi}{4} &=\int_{0}^{1} \tan ^{-1}(2 x-1) d x \stackrel{2x-1\mapsto x}{=} \frac{1}{2} \int_{-1}^{1} \tan ^{-1} x d x=0
\end{aligned}
$$
Hence
$$\boxed{\int_{0}^{1} \tan ^{-1}\left(1-\frac{1}{x}\right) dx =-\frac{\pi}{4} }$$
A: $$\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}$
A: \begin{align}J&=\int_{0}^{1} \tan^{-1}\left(1-\frac1x\right)dx\\
&\overset{u=\frac1x-1}=-\int_0^\infty \frac{\arctan u}{(1+u)^2}du\\
&\overset{z=\frac1u}=-\int_0^\infty \frac{\arctan\left(\frac{1}{z}\right)}{(1+z)^2}dz\\
&=\frac{1}{2}\times-\frac{\pi}{2}\int_0^\infty \frac{1}{(1+u)^2}du\\
&=\frac{1}{2}\times\frac{\pi}{2}\Big[\frac{1}{1+u}\Big]_0^\infty\\
&=\boxed{-\frac{\pi}{4}}
\end{align}
A: Well, let's solve the indefinite integral:
$$\mathcal{I}\left(x\right):=\int\arctan\left(1-\frac{1}{x}\right)\space\text{d}x\tag1$$
Let's first use IBP with $\text{f}\left(x\right)=\arctan\left(1-\frac{1}{x}\right)$ and $\text{g}'\left(x\right)=1$, so we can write:
$$\mathcal{I}\left(x\right)=x\arctan\left(1-\frac{1}{x}\right)-\int\frac{x}{2x^2-2x+1}\space\text{d}x\tag2$$
Using partial fractions we can write:
$$\frac{x}{2x^2-2x+1}=\frac{4x-2}{4\left(2x^2-2x+1\right)}+\frac{1}{2\left(2x^2-2x+1\right)}\tag3$$
Subsitute $\text{u}:=2x^2-2x+1$, so we get:
\begin{equation}
\begin{split}
\mathcal{I}\left(x\right)&=x\arctan\left(1-\frac{1}{x}\right)-\frac{1}{4}\int\frac{1}{\text{u}}\space\text{du}-\frac{1}{2}\int\frac{1}{2x^2-2x+1}\space\text{d}x\\
\\
&=x\arctan\left(1-\frac{1}{x}\right)-\frac{1}{4}\cdot\ln\left|\text{u}\right|+\text{C}_1-\frac{1}{2}\int\frac{1}{2x^2-2x+1}\space\text{d}x\\
\\
&=x\arctan\left(1-\frac{1}{x}\right)-\frac{\ln\left|2x^2-2x+1\right|}{4}+\text{C}_1-\frac{1}{2}\int\frac{1}{2x^2-2x+1}\space\text{d}x
\end{split}\tag4
\end{equation}
Now, let's complete the square on the last integral and substitute $\text{s}=x\sqrt{2}-\frac{1}{\sqrt{2}}$. After that substitute $\text{p}=\sqrt{2}\text{s}$, so we get:
\begin{equation}
\begin{split}
\mathcal{I}\left(x\right)&=x\arctan\left(1-\frac{1}{x}\right)-\frac{\ln\left|2x^2-2x+1\right|}{4}+\text{C}_1-\frac{1}{\sqrt{2}}\int\frac{1}{2\text{s}^2+1}\space\text{ds}\\
\\
&=x\arctan\left(1-\frac{1}{x}\right)-\frac{\ln\left|2x^2-2x+1\right|}{4}+\text{C}_1-\frac{1}{2}\int\frac{1}{\text{p}^2+1}\space\text{dp}\\
\\
&=x\arctan\left(1-\frac{1}{x}\right)-\frac{\ln\left|2x^2-2x+1\right|}{4}+\text{C}_1-\frac{1}{2}\cdot\arctan\left(\text{p}\right)+\text{C}_2\\
\\
&=x\arctan\left(1-\frac{1}{x}\right)-\frac{\ln\left|2x^2-2x+1\right|}{4}+\text{C}_1-\frac{\arctan\left(\sqrt{2}\text{s}\right)}{2}+\text{C}_2\\
\\
&=x\arctan\left(1-\frac{1}{x}\right)-\frac{\ln\left|2x^2-2x+1\right|}{4}+\text{C}_1-\frac{\arctan\left(\sqrt{2}\left(x\sqrt{2}-\frac{1}{\sqrt{2}}\right)\right)}{2}+\text{C}_2\\
\\
&=x\arctan\left(1-\frac{1}{x}\right)-\frac{\ln\left|2x^2-2x+1\right|}{4}-\frac{\arctan\left(2x-1\right)}{2}+\underbrace{\text{C}_1+\text{C}_2}_{:=\space\text{C}}\\
\\
&=x\arctan\left(1-\frac{1}{x}\right)-\frac{\ln\left|2x^2-2x+1\right|}{4}-\frac{\arctan\left(2x-1\right)}{2}+\text{C}
\end{split}\tag5
\end{equation}

Now, solving your problem we see:
$$\int_0^1\arctan\left(1-\frac{1}{x}\right)\space\text{d}x=\mathcal{I}\left(1\right)-\mathcal{I}\left(0\right)=-\frac{\pi}{8}-\frac{\pi}{8}=-\frac{\pi}{4}\tag6$$
A: The equality $\arctan(x)+\operatorname{arccot}(x)=\frac\pi2$ holds when $x>0$, but when $x<0$ you have $\arctan(x)+\operatorname{arccot}(x)=-\frac\pi2$, and $\frac x{x-1}<0$ when $x\in[0,1)$. So, you actually have\begin{align}I&=\int_0^1-\frac\pi2-\operatorname{arccot}\left(\frac x{x-1}\right)\,\mathrm dx\\&=\int_0^1-\frac\pi2-\arctan\left(\frac{x-1}x\right)\,\mathrm dx\\&=-\frac\pi2-I,\end{align}and therefore $I=-\frac\pi4$ indeed.
