TITLE: Functional equation $ f(x) + f\left(1-\frac{1}{x}\right) = \tan^{-1}(x) $ and definite integral
QUESTION [11 upvotes]: Let $f(x)$ be a function $f :\mathbb{R}\to \mathbb{R}$ such that
$$ f(x) + f\left(1-\frac{1}{x}\right) = \tan^{-1}(x) $$
for all real $x$ except $0$.
Find $\int_0^1f(x)\ \mathrm dx$.

My approach till now:
Put $x = \frac{1}{x}$ in the functional equation and consider the domain of integration $(0,1)$ such that $\tan^{-1}\frac{1}{x} = \cot^{-1}(x)$ and add the original functional equation and the resulting equation after the substitution to get:
$$f(x) + f(1-x) = \frac{\pi}{2} - f\left(\frac{1}{x}\right) - f\left(1-\frac{1}{x}\right)$$
and integrate both sides from $0$ to $1$.
Let $I = \int_0^1f(x)\ \mathrm dx $, then LHS of above functional equation becomes $2I$. Now I am not able to evaluate the RHS, some $\frac{\ln(2)}{2}$ term always creeps up and doesn't gets cancelled and its not even in the answer.
Please help me with this problem.

REPLY [8 votes]: Let $g(x)=1-\frac1x$. Then $g(g(x))=\frac1{1-x}$ and $g(g(g(x)))=x$.
Thus,
$$
f(x)+f(g(x))=\tan^{-1}(x)\tag1
$$
$$
f(g(x))+f(g(g(x)))=\tan^{-1}(g(x))\tag2
$$
$$
f(g(g(x)))+f(x)=\tan^{-1}(g(g(x)))\tag3
$$
Since $2f(x)=(1)-(2)+(3)$, we get
$$
f(x)=\frac12\left(\tan^{-1}(x)-\tan^{-1}(g(x))+\tan^{-1}(g(g(x)))\right)\tag4
$$
As mentioned in comments, this function is not continuous:

What is interesting is that the derivative of this function is continuous (if we subtract $\frac\pi2$ from $f$ in $[0,1]$ to counter the jump discontinuities):

In any case,
$$
\begin{align}
&\int_0^1f(x)\,\mathrm{d}x\\
&=\frac12\left(\int_0^1\tan^{-1}(x)\,\mathrm{d}x-\int_0^1\tan^{-1}(g(x))\,\mathrm{d}x+\int_0^1\tan^{-1}(g(g(x)))\,\mathrm{d}x\right)\tag5\\
&=\frac12\left(\int_0^1\tan^{-1}(x)\,\mathrm{d}x-\int_{-\infty}^0\tan^{-1}(x)\,\mathrm{d}g(g(x))+\int_1^\infty\tan^{-1}(x)\,\mathrm{d}g(x)\right)\tag6\\
&=\scriptsize\frac12\left(\frac\pi4-\color{#C00}{\int_0^1\frac{x}{1+x^2}\,\mathrm{d}x}+\color{#090}{\int_{-\infty}^0\frac1{(1-x)\left(1+x^2\right)}\,\mathrm{d}x}+\frac\pi2-\color{#00F}{\int_1^\infty\frac{x-1}{x\left(1+x^2\right)}\,\mathrm{d}x}\right)\tag7\\
&=\frac12\left(\frac\pi4-\color{#C00}{\frac{\log(2)}2}
+\color{#090}{\frac\pi4}
+\frac\pi2-\color{#00F}{\frac{\pi-2\log(2)}4}\right)\tag8\\[3pt]
&=\frac{3\pi}8\tag9
\end{align}
$$
Explanation:
$(5)$: apply $(4)$
$(6)$: apply $g$ and $g\circ g$ to get $\tan^{-1}(x)$ in each integral
$(7)$: integrate by parts
$(8)$: evaluate the integrals by partial fractions
$(9)$: simplify