Find $a \in \mathbb{R}$ such that $\int_1^{\infty}\left(\frac{1}{x+2} - \frac{ax}{x^2+1}\right) dx$ converges. The question goes like this:
'Find $a \in \mathbb{R}$ such that $\int_1^{\infty}\left(\frac{1}{x+2} - \frac{ax}{x^2+1}\right) dx$ converges.'
After computing this integral (maybe in a false way) I end up with the $\lim_  {x\to \infty}\ln(-x-2) + \frac{a\ln\left(\frac{x^2+1}{2}\right)}{2}$, which seems to diverge for all values of a.
Is there something I'm doing wrong?
 A: 
After computing this integral (maybe in a false way) I end up with the $\lim_  {x\to \infty}\ln(-x-2) + \frac{a\ln\left(\frac{x^2+1}{2}\right)}{2}$, which seems to diverge for all values of a.

Some of this is not true. The antiderivative of $f(x) = \dfrac{1}{x+2}-\dfrac{ax}{x^{2}+1}$ is $F(x) = \ln\left(\left|x+2\right|\right)-\dfrac{a\ln\left(x^2+1\right)}{2}$, so using the Fundamental Theorem of Calculus yields
$$\displaystyle \lim_{t\to\infty}F(t) - F(1) = \lim_{t\to\infty}\left(\ln\left(\left|t+2\right|\right)-\frac{a\ln\left(t^{2}+1\right)}{2}\right) - \left(\ln\left(\left|1+2\right|\right)-\frac{a\ln\left(1^{2}+1\right)}{2}\right),$$
which diverges when $a\in \mathbb{R} \backslash \left\{1\right\}$. In fact, we can get rid of the absolute values since we are integrating over the interval $[1,\infty)$ and we can ignore the last expression since it is a constant.
(Answer) To prove $a=1$ is the only value for which this improper integral converges, we can naively evaluate the limit as follows:
$$
\eqalign{
\displaystyle
\lim_{t\to\infty}\left(\ln\left(t+2\right)-\frac{a}{2}\ln\left(t^{2}+1\right)\right) &= \lim_{t\to\infty}\frac{a}{2}\ln\left(t^{2}+1\right)\left(\frac{2}{a}\frac{\ln\left(t+2\right)}{\ln\left(t^{2}+1\right)}-1\right) \cr
&= \lim_{t\to\infty}\frac{a}{2}\ln\left(t^{2}+1\right)\left(\frac{2}{a}\frac{\ln\left(t+2\right)}{\ln\left(1+\frac{1}{t^{2}}\right)+2\ln\left(t\right)}-1\right) \cr
&= \left(\lim_{t\to\infty}\frac{a}{2}\ln\left(t^{2}+1\right)\right) \cdot \left(\lim_{t\to\infty}\frac{2}{a}\frac{\ln\left(t+2\right)}{\ln\left(1+\frac{1}{t^{2}}\right)+2\ln\left(t\right)}-1\right) \cr
&= \left(\lim_{t\to\infty}\frac{a}{2}\ln\left(t^{2}+1\right)\right) \cdot \left(\lim_{t\to\infty}\frac{2}{a}\frac{\ln\left(t+2\right)}{0+2\ln\left(t\right)}-1\right) \cr
&= \left(\lim_{t\to\infty}\frac{a}{2}\ln\left(t^{2}+1\right)\right) \cdot \left(\frac{1}{a}\lim_{t\to\infty}\frac{\frac{d}{dt}\ln\left(t+2\right)}{\frac{d}{dt}\ln\left(t\right)}-1\right) \cr
&= \left(\infty \cdot \dfrac{a}{2}\right) \cdot \left(\dfrac{1}{a}(1)-1\right) \cr
&= \infty \left(\frac{1-a}{2}\right).
}
$$
Notice that any $a \in \mathbb{R} \backslash \left\{1\right\}$ results in the limit diverging. It is only when $a=1$ that we get an indeterminate form $\infty \cdot 0$.
We can go back to evaluating the limit but with $a=1$, yielding
$$
\eqalign{
\displaystyle
\lim_{t\to\infty}
\left(\ln\left(t+2\right)-\frac{1}{2}\ln\left(t^{2}+1\right)\right) &= \ln\left(\lim_{t\to\infty}\frac{t+2}{\sqrt{t^{2}+1}}\right) \cr
&= \ln\left(\lim_{t\to\infty}\frac{t+2}{\left|t\right|\sqrt{1+\frac{1}{t^{2}}}}\right) \cr
&= \ln\left(\lim_{t\to\infty}\frac{t}{\left|t\right|\sqrt{1+\frac{1}{t^{2}}}} + \lim_{t\to\infty}\frac{2}{\left|t\right|\sqrt{1+\frac{1}{t^{2}}}}\right) \cr
&= \ln\left(1+0\right) \cr
&= 0. \cr
}
$$
Since the limit equals $0$, the integral ultimately equals $\ln\left(\sqrt{2}\right)-\ln\left(3\right)$, after some simplifying.
Please do not hesitate to ask any questions if anything is unclear.
A: Combining fractions,
$$\frac1{x+2} - \frac{ax}{x^2 + 1} = \frac{x^2 + 1 - ax(x+2)}{(x+2)(x^2+1)} = \frac{(1-a)x^2-2ax+1}{(x+2)(x^2+1)}$$
The integral converges when the quadratic term in the numerator vanishes.
A: Collecting the integrand, we have $\int_1^{\infty}\frac{(1-a)x^2-2ax+1}{(x+2)(x^2+1)}dx$.
Note: The text books everywhere write the limit comparison test for improper integrals with positive integrands: https://services.math.duke.edu/~cbray/Stanford/2003-2004/Math%2042/limitcomp.pdf.
If $a=1$, the integral is $-\int_1^{\infty}\frac{2x-1}{(x+2)(x^2+1)}dx$ and it converges by limit comparison test for improper integrals, comparing $\int_1^{\infty}\frac{2x-1}{(x+2)(x^2+1)}dx$ with the integral $\int_1^{\infty}\frac{2x+2}{(x+2)(x^2+1)}dx$. (The test is simple: Take the ratio of the integrands of the integrals compared, if the limit of this ratio when $x\rightarrow\infty$ is positive real number, the improper integrals have the same character.)
If $a\neq 1$, the integral can be splitted as $\frac{a-2a^2}{1-a}\int_1^{\infty}\frac{1}{(x+2)(x^2+1)}dx+(1-a)\int_1^{\infty}\frac{(x-\frac{a}{1-a})^2+1}{(x+2)(x^2+1)}dx$. The first integral clearly converges. The second integral diveges by limit comparison test, comparing $\int_1^{\infty}\frac{(x-\frac{a}{1-a})^2+1}{(x+2)(x^2+1)}dx$ with $\int_1^{\infty}\frac{x^2+1}{(x+2)(x^2+1)}dx$.
