# Verifying the mechanics behind gravitational force of an infinitely long rod

I have a rod of infinite length and uniform length density $\mu$ and I am interested in calculating the force experienced by a small test mass $m$ a distance $\rho$ away from the rod.

For simplicity, I'm going to place this rod along the z-axis so that the position of the mass is $<\rho\cos\theta,\rho\sin\theta,0>$ and the position of the rod is $<0,0,z>$ where I'm working in cylindrical coordinates such that $\theta$ is the azimuthal angle. Then, the total gravitational force is: $$\mathbf{F}=-Gm\int_{-\infty}^{\infty}\dfrac{\mu}{(\rho^2+z^2)^{3/2}}(-\rho\cos\theta\ \hat{x}-\rho\sin\theta\ \hat{y}+z\ \hat{z})\ dz$$ Have I made a mistake anywhere? I think my train of thought is fine right now. We find that the x and y components of the force are $2Gm\mu\cos\theta/\rho$ and $2Gm\mu\sin\theta/\rho$ respectively such that the magnitude of the force is: $$F=\dfrac{2Gm\mu}{\rho}$$

I guess it makes sense to write this force in cylindrical coordinates such that $$\mathbf{F}=\dfrac{2Gm\mu}{\rho}\hat{\rho}$$ This is all fine until I try to define a potential energy: $$U=-\int F\cdot\ d\mathbf{l}=-2Gm\mu\int_{\infty}^{\rho}\dfrac{1}{\rho'}\ d\rho'$$ which blows up. My guess is that I must chose another reference frame but is there a particular convention or preferred choice? Other than that, is my logic flawed anywhere?

Since absolute potential energy is arbitrary, you can define $U=0$ at an arbitrary point, or only talk about differences in potential energy between different points.