Compute $\int_0^n \left[\frac x {x+1} + \frac x {2x+4} + \frac x {3x+9} + \cdots\right] \, dx$ for $x>0$ I want to compute $\displaystyle \int_0^n \left[\frac x {x+1} + \frac x {2x+4} + \frac x {3x+9} + \cdots \right] \, dx$ for $x>0$
My attempt: The integrand can be written as a sum of $\displaystyle f_k(x)=\frac x{kx+k^2}$ which is positive for $x>0$, can we interchange sum and integral here? If so, then $\displaystyle \int_0^n \frac x{kx+k^2}=1-\log(2)$, so the given integral diverges?
 A: We have
\begin{align}
f(x) & = \sum_{k=1}^{\infty} \dfrac{x}{kx+k^2} = \sum_{k=1}^{\infty} \left(\dfrac1k - \dfrac1{k+x} \right) = \sum_{k=1}^{\infty} \int_0^1 \left(t^{k-1} - t^{k+x-1}\right)dt\\
& = \int_0^1 (1-t^x) \left(\sum_{k=1}^{\infty} t^{k-1} \right) dt = \int_0^1 \dfrac{1-t^x}{1-t} dt
\end{align}
We now have
$$I_n = \int_0^n f(x) dx = \int_0^n \int_0^1 \dfrac{1-t^x}{1-t} dt dx = \int_0^1 \dfrac{n + \dfrac{1-t^n}{\log(t)}}{1-t}dt$$
From WolframAlpha for $k=1,2,3,4,5$, we get the value of
$$J_k = \int_0^1 \left(\dfrac1{1-t} + \dfrac{t^{k-1}}{\log(t)} \right) dt = \gamma + \log(k)$$
Assuming this is true in general and noting that $I_n = \displaystyle \sum_{k=1}^n J_k$, we get that,
$$I_n = \sum_{k=1}^n J_k = n \gamma + \log(n!)$$
A: If I am reading the sum correctly,
$$
\begin{align}
\sum_{k=1}^\infty\frac{x}{kx+k^2}
&=\sum_{k=1}^\infty\left(\frac1k-\frac1{k+x}\right)\\
&=\psi(x+1)+\gamma\\
&=\frac{\mathrm{d}}{\mathrm{d}x}\log(\Gamma(x+1))+\gamma
\end{align}
$$
where $\psi(x)$ is the digamma function and $\Gamma(x)$ is the Gamma function.
Thus,
$$
\begin{align}
\int_0^n\sum_{k=1}^\infty\frac{x}{kx+k^2}\,\mathrm{d}x
&=\log(\Gamma(n+1))-\log(\Gamma(1))+\gamma n\\
&=\log(n!)+\gamma n
\end{align}
$$
A: \begin{align}
\sum_{k = 1}^{n}{x \over kx + k^{2}}
&=
\sum_{k = 1}^{n}\left({1 \over k} - {1 \over k + x}\right)
=
\sum_{k = 0}^{n - 1}{1 \over k + 1} - \sum_{k = 0}^{n - 1}{1 \over k + x + 1}
\\[3mm]&=
\left\lbrack\Psi\left(1 + n\right) - \Psi\left(1\right)\right\rbrack
-
\left\lbrack\Psi\left(1 + n + x\right) - \Psi\left(x + 1\right)\right\rbrack
\end{align}
\begin{align}
&\int_{0}^{n}\sum_{k = 1}^{n}{x \over kx + k^{2}}\,{\rm d}x
=
\left\lbrack\Psi\left(1 + n\right) - \Psi\left(1\right)\right\rbrack n
-
\left\lbrack%
\ln\Gamma\left(1 + 2n\right)
-
\ln\Gamma\left(1 + n\right)
\right\rbrack
\\[3mm]&+
\\[3mm]&
\left\lbrack%
\ln\Gamma\left(1 + n\right)
-
\ln\Gamma\left(1\right)
\right\rbrack
=
1 + \left\lbrack\Psi\left(n\right) + \gamma\right\rbrack n
-
\ln\left(2n\right)
-
\ln\Gamma\left(2n\right)
+
2\ln\left(n\right)
+
2\ln\Gamma\left(n\right)
\end{align}
$$
\begin{array}{|c|}\hline\\
\color{#ff0000}{%
\int_{0}^{n}\sum_{k = 1}^{n}{x\,{\rm d}x \over kx + k^{2}}
=
1 - \ln\left(2\right) + \left\lbrack\Psi\left(n\right) + \gamma\right\rbrack n
-
\ln\Gamma\left(2n\right)
+
\ln\left(n\right)
+
2\ln\Gamma\left(n\right)}
\\ \\ \hline
\end{array}
$$
\begin{align}
&\left.
\int_{0}^{n}\sum_{k = 1}^{n}{x \over kx + k^{2}}\,{\rm d}x
\right\vert_{n\ \gg\ 1}
\!\!\!\!\!\!\!\!\!\!\sim
1 - \ln\left(2\right) + \left\lbrack\ln\left(n\right) - {1 \over 2n} + \gamma\right\rbrack n
+
\ln\left(n\right)
+
\left({1 \over 2} - 2n\right)\ln\left(2\right) - {1 \over 2}\,\ln\left(n\right)
\\[3mm]&=
n\,\ln\left(n\right) -
\left\lbrack 2\ln\left(2\right) - \gamma\right\rbrack n
+
{1 \over 2}\,\ln\left(n\right)
+
{1 \over 2}\left\lbrack 1 - \ln\left(2\right)\right\rbrack
\end{align}
$$
\begin{array}{|c|}\hline\\
\color{#ff0000}{\large%
\int_{0}^{n}\sum_{k = 1}^{n}{x \over kx + k^{2}}\,{\rm d}x\
\sim\
n\,\ln\left(n\right)\,,
\qquad
n \gg 1}
\\ \\ \hline
\end{array}
$$
