TITLE: Prove two similiar integral equalities
QUESTION [5 upvotes]: I am looking to show that
$$ \begin{align*}
I_1 & = \int_{ma}^{na} \frac{ \log(x - a) }{x^2 + a^2 } 
      = \frac{\log (2a^2)}{2a} \bigl[ \arctan n + \arctan m\bigr] \\ 
I_2 & = \int_{a/m}^{a/n} \frac{\log(x + a) }{ x^2 + a^2 } 
      = \frac{\log (2a^2)}{2a}\bigl[ \arctan \frac{1}{m} + \arctan \frac{1}{n} \bigr]
\end{align*} $$
Given that $nm = n + m + 1$. Now here the substitutions suggested to solve the integrals are given as 
$$ I_1 \, \text{let} \, x = \frac{at + a^2}{t - a} 
  \quad \text{and} \quad
  I_2 \, \text{let} \, x = \frac{-at + a^2}{t + a}  
$$
but even after using these substitutions I am not closer to a solution. 
Can anyone give some hints on evaluating the integrals? (I already have proved the equality using the method in the first post, but I was intrigued by the integrals in the second post. 
Even more so by the fact that the poster seems to trivialize these integrals, and that they stumpled all of my CAS tools. Are there any clever, and smart ways to attack these integrals?

REPLY [2 votes]: $$
\begin{align}
\int_{ma}^{na}\frac{\log(x-a)}{x^2+a^2}\,\mathrm{d}x
&=\frac1a\int_m^n\frac{\log(a)+\log(x-1)}{x^2+1}\,\mathrm{d}x\tag{1}\\
&=\frac{\log(a)}a\Big[\arctan(n)-\arctan(m)\Big]\\
&+\frac1a\int_m^n\frac{\log(x-1)}{x^2+1}\,\mathrm{d}x\tag{2}\\
&=\frac{\log(a)}a\Big[\arctan(n)-\arctan(m)\Big]\\
&+\frac1{a\sqrt2}\int_{\log\left(\frac{m-1}{\sqrt2}\right)}^{\log\left(\frac{n-1}{\sqrt2}\right)}\frac{\color{#C00000}{u}+\color{#00A000}{\log(\sqrt2)}}{e^{2u}+\sqrt2e^u+1}e^u\,\mathrm{d}u\tag{3}\\
&=\frac{\log(a)}a\Big[\arctan(n)-\arctan(m)\Big]\\
&+\frac1{a\sqrt2}\int_{\log\left(\frac{m-1}{\sqrt2}\right)}^{\log\left(\frac{n-1}{\sqrt2}\right)}\frac{\log(\sqrt2)}{e^{2u}+\sqrt2e^u+1}e^u\,\mathrm{d}u\tag{4}\\
&=\frac{\log(a)}a\Big[\arctan(n)-\arctan(m)\Big]\\
&+\frac{\log(\sqrt2)}{a}\int_m^n\frac{\mathrm{d}x}{x^2+1}\tag{5}\\
&=\frac{\log(a)}a\Big[\arctan(n)-\arctan(m)\Big]\\
&+\frac{\log(\sqrt2)}{a}\Big[\arctan(n)-\arctan(m)\Big]\tag{6}\\
&=\frac{\log(a\sqrt2)}a\Big[\arctan(n)-\arctan(m)\Big]\tag{7}
\end{align}
$$
Justification:
$(1)$: substitute $x\mapsto ax$
$(2)$: integrate the $\log(a)$ term
$(3)$: substitute $u=\log\left(\frac{x-1}{\sqrt2}\right)$
$(4)$: $\log\left(\frac{n-1}{\sqrt2}\right)+\log\left(\frac{m-1}{\sqrt2}\right)=0$; $\frac{e^u}{e^{2u}+\sqrt2e^u+1}$ is even; drop the odd part: $\color{#C00000}{u}$
$(5)$: reverse the substitution from $(3)$
$(6)$: integrate
$(7)$: combine
\begin{align}
\int_{a/m}^{a/n}\frac{\log(x+a)}{x^2+a^2}\,\mathrm{d}x
&=\int_{m/a}^{n/a}\frac{\log(1+ax)-\log(x)}{1+a^2x^2}\,\mathrm{d}x\tag{8}\\
&=\frac1a\int_m^n\frac{\log(1+x)-\log(x)+\log(a)}{1+x^2}\,\mathrm{d}x\tag{9}\\
&=\frac{\log(a)}{a}\Big[\arctan(n)-\arctan(m)\Big]\\
&+\frac1a\int_m^n\frac{\log(1+x)-\log(x)}{1+x^2}\,\mathrm{d}x\tag{10}\\
&=\frac{\log(a)}{a}\Big[\arctan(n)-\arctan(m)\Big]\\
&+\frac1{a\sqrt2}\int_{\log\left(\frac{m-1}{\sqrt2}\right)}^{\log\left(\frac{n-1}{\sqrt2}\right)}\frac{\log\left(\frac{2+\sqrt2e^u}{1+\sqrt2e^u}\right)}{e^{2u}+\sqrt2e^u+1}e^u\,\mathrm{d}u\tag{11}\\
&=\frac{\log(a)}{a}\Big[\arctan(n)-\arctan(m)\Big]\\
&+\frac1{a\sqrt2}\int_{\log\left(\frac{m-1}{\sqrt2}\right)}^{\log\left(\frac{n-1}{\sqrt2}\right)}\frac{\log(\sqrt2)}{e^{2u}+\sqrt2e^u+1}e^u\,\mathrm{d}u\tag{12}\\
&=\frac{\log(a\sqrt2)}a\Big[\arctan(n)-\arctan(m)\Big]\tag{13}
\end{align}
Justification:
$\ \:(8)$: substitute $x\mapsto1/x$
$\ \:(9)$: substitute $x\mapsto x/a$
$(10)$: integrate the $\log(a)$ term
$(11)$: substitute $u=\log\left(\frac{x-1}{\sqrt2}\right)$
$(12)$: $\log\left(\frac{n-1}{\sqrt2}\right)+\log\left(\frac{m-1}{\sqrt2}\right)=0$; $\frac{e^u}{e^{2u}+\sqrt2e^u+1}$ is even; even part of $\log\left(\frac{2+\sqrt2e^u}{1+\sqrt2e^u}\right)$ is $\log(\sqrt2)$
$(13)$: $(12)$ is the same as $(4)$
Motivation:
Since the condition given is $(n-1)(m-1)=2$, I chose the substitution $u=\log\left(\frac{x-1}{\sqrt2}\right)$, so that $[m,n]$ is mapped to an interval symmetric about the origin. Then we can ignore the odd part of the integrand. If we are lucky, the even part of the integrand is easier to deal with.