Evaluating volume integral for electric potential in an infinite cylinder with uniform charge density Suppose I have an infinitely long cylinder of radius $a$, and uniform volume charge density $\rho$. I want to brute force my way through a calculation of the potential on the interior of the cylinder using the relation:
$$
\Phi(\mathbf{x}) = \frac{1}{4\pi \epsilon_0} \int d^3 x' \frac{\rho(\mathbf{x}')}{|\mathbf{x} - \mathbf{x}'|}
$$
To simplify the integral, I place my axes so that $\mathbf{x}$ points along the $x$-axis. Thus
$$
\mathbf{x} = x \mathbf{\hat{x}}
$$
$$
\mathbf{x}' 
= r' \cos \phi' \mathbf{\hat{x}} 
+ r' \sin \phi' \mathbf{\hat{y}}
+ z' \mathbf{\hat{z}}
$$
$$
\rho(\mathbf{x}') = \rho
$$
The resulting volume integral is then:
$$
\Phi(\mathbf{x})
= \frac{\rho}{4 \pi \epsilon_0} \int_{-\infty}^{\infty} dz'
\int_0^{2\pi} d\phi'
\int_0^a r' dr'
\frac{1}{\sqrt{x^2 + r'^2 - 2xr'\cos\phi' + z'^2}}
$$
How do I evaluate this integral? I've tried to do some substitutions ($\mu = \cos \phi'$, $z' = \sinh\theta$), but nothing has given anything workable.
To be clear, I understand that this problem is reasonably easily solvable by first finding the electric field with Gauss's law and then taking the line integral. I would just like to know how to take this integral and, if possible, get some insight into why the integral in this easy problem is stupid hard.

I drop the constant and focus on the integral, also the prime sign:
$$
\Phi(\mathbf{x})
= \int_{-\infty}^{\infty} dz
\int_0^{2\pi} d\phi
\int_0^a r dr
\frac{1}{\sqrt{x^2 + r^2 - 2xr\cos\phi + z^2}}
$$
The integral is divergent. To remove the divergence is to change the reference point of the potential from $x=\infty$ to $x=0$. Thus, I will change the integrand back to an integration form, and change the lower limit, which only change an infinite constant to the potential.
$$
 \frac{1}{\sqrt{x^2 + r^2 - 2xr\cos\phi + z^2}} =- \int^x_\infty d\xi \frac{\xi - r\cos \phi}{\left(\xi^2 + r^2 - 2\xi r\cos\phi + z^2\right)^{3/2}}\\
\to -\int^x_0 d\xi \frac{\xi - r\cos \phi}{\left(\xi^2 + r^2 - 2\xi r\cos\phi + z^2\right)^{3/2}}
$$
The new potential from:
$$
\Phi(\mathbf{x}) = -\int^x_0 d\xi \int^{2\pi}_0 d\phi \int_0^a rdr\int_{-\infty}^\infty  dz \frac{\xi - r\cos \phi}{\left(\xi^2 + r^2 - 2\xi r\cos\phi + z^2\right)^{3/2}}\\
= -\int^x_0 d\xi \int^{2\pi}_0 d\phi \int_0^a rdr \frac{2(\xi - r\cos \phi)}{\left(\xi^2 + r^2 - 2\xi r\cos\phi\right)}  \to I_1 - I_2
$$
The integral of $z$ can be carried out by triangular substitution. Next, I will try to integrate over $\phi$, by complex contour integral in the unit circle. Details refer to the appendixes in the bottom.
$$
I_1 = 2\xi \int^{2\pi}_0 d\phi  \frac{1}{\left(\xi^2 + r^2 - 2\xi r\cos\phi\right)} = \frac{4\pi\xi}{r_>^2-r_<^2}
$$
$$
I_2 = 2 r \int^{2\pi}_0 d\phi  \frac{\cos\phi}{\left(\xi^2 + r^2 - 2\xi r\cos\phi\right)} =\frac{4\pi r}{r_>^2-r_<^2} \frac{r_<}{r_>}
$$
The above integral is done by change $Z = e^{i\phi}$ and turn the integral into a closed contour integral on the unit circle. $r_>$ is the larger one between $r$ and $\xi$, $r_<$ the smaller one.
$$
\Phi(\mathbf{x}) =- 4 \pi \int^x_0 d\xi \int_0^a rdr \left[  \xi - r\frac{r_<}{r_>} \right] \frac{1}{r_>^2-r_<^2}
$$
For  $x < a$ :
$$
\Phi(\mathbf{x}) =- 4 \pi \int^x_0 d\xi \left\{\int_0^\xi rdr \left[  \xi - r\frac{r}{\xi} \right] \frac{1}{\xi^2-r^2} + \int_\xi^a rdr \left[  \xi - r\frac{\xi}{r} \right] \frac{1}{r^2-\xi^2} \right\} \\
=- 4 \pi \int^x_0 d\xi \left\{\int_0^\xi rdr \frac{1}{\xi} + 0 \right\} =- 2 \pi \int^x_0 \xi d \xi = -\pi x^2
$$
For  $x > a$ :
$$
\Phi(\mathbf{x}) =- 4 \pi \int^a_0 rdr \left\{\int_0^r d\xi \left[  \xi - r\frac{\xi}{r} \right] \frac{1}{r^2-\xi^2}  + \int_r^x d\xi \left[  \xi - r\frac{r}{\xi} \right] \frac{1}{\xi^2-r^2} \right\} \\
=- 4 \pi \int^a_0 rdr \left\{ 0 + \int_r^x d\xi \frac{1}{\xi} \right\}\\
 =- \pi a^2 \left( 2 \ln x - 2 \ln a + 1 \right).
$$
A first quick check of the result is the continuity of the potential as $x = a$, where both forms render $\Phi(a) = -\pi a^2$.
Appendix A 

For $0< b < 1$ the complete integral over angle $\phi$:
$$
I_1 = \int^{2\pi}_0 d\phi  \frac{1}{\left(1 + b^2 - 2b \cos\phi\right)} = \frac{2\pi}{1-b^2}
$$
Let $Z = e^{i\phi}$, hence $d\phi= -i \frac{dZ}{Z}$. Write $I_1$ as
$$
I_1 = -i \oint_{unit- circle}  \frac{dZ}{Z \left(1 + b^2 \right) - b \left( Z^2 + 1 \right)} =  + \frac{i}{b} \oint_{unit- circle}  \frac{dZ}{(Z-b)(Z-\frac{1}{b})}  \\
= \frac{-2\pi}{b} Res(b) = \frac{-2\pi}{b} \frac{1}{b-\frac{1}{b}} = \frac{2\pi}{1-b^2}
$$
Appendix B

For $0< b < 1$ the complete integral over angle $\phi$:
$$
I_2 = \int^{2\pi}_0 d\phi  \frac{\cos\phi}{\left(1 + b^2 - 2b \cos\phi\right)} = \frac{2\pi b}{1  -b^2}
$$
Let $Z = e^{i\phi}$:
$$
I_2 = \frac{i}{2b} \oint_{unit- circle}  \frac{Z^2 + 1}{(Z-b)(Z-\frac{1}{b})} \frac{dZ}{Z}\\
= \frac{i}{2b} 2\pi i \left\{ Res(0) + Res(b)\right\} = - \frac{\pi}{b}  \left\{ 1 - \frac{1+b^2}{1-b^2}\right\} = \frac{2\pi b}{1  -b^2}
$$
