On gravitational pull between a particle and a rod with constant density Suppose we are given a rod of constant density $\rho$ and a particle of mass $m$. The distance of the particle from the rod is $d > 0$. Also, suppose $a < b$. What I want to achieve is to compute the gravitational pull between the particle and the part of the rod for which $x \in [a, b]$. We set the $x$-axis such that the closest point on the rod to the particle occurs at $x = 0$.
Below is my best attempt.
\begin{aligned}
F &= \sum \frac{m \; \Delta m^\prime}{L(x)^2} \\
  &= \sum \frac{m\rho \Delta x}{L(x)^2},
\end{aligned}
where $L(x) = \sqrt{d^2 + x^2}$.
The above may (?) be interpretted as a Riemann integral, which leads us to
\begin{aligned}
F &= \int_a^b \frac{m\rho}{d^2 + x^2} \mathrm{d}x \\
  &= \frac{m\rho}{d} \Bigg[ \arctan\Bigg(\frac{x}{d}\Bigg) \Bigg]_{x = a}^{x = b}.
\end{aligned}
Now, if we take $a \rightarrow -\infty$ and $b \rightarrow \infty$, we have
\begin{aligned}
F &= \frac{m\rho}{d} \Bigg[ \frac{\pi}{2} - \Bigg( -\frac{\pi}{2} \Bigg) \Bigg] \\
  &= \frac{\pi m\rho}{d}.
\end{aligned}
Question: is that calculation correct? If $d \rightarrow 0+$, $F \rightarrow \infty$?
 A: It is always useful to go through exercises like this rather than looking up the answer in books!
Paweł Korzeb is right that you have forgotten that the force is a vector rather than a scalar. I thought I'd work through this in an outline way to show you how it works.
The letter $d$ works rather well for differentials, so I will use $r$ for the distance between the particle and the rod. And I'll set $mG=1$ to simplify the notation.
Consider an infinitesimal interval $d x$ on the rod with coordinate $x$ - this being a distance along the rod, with the closest point to the particle being defined as $x=0$. This can also be defined in terms of the direction $\theta$ from the particle to the rod, with the closest point to the particle being defined as $\theta=0$. These two coordinates are related by: $$x=r\tan\theta$$
The distance from the particle to a point with coordinate $x$ is $\sqrt {r^2+x^2}$, so the gravitational force is the inverse square of that, multiplied by the length of the interval: thus $$\frac 1 {r^2+x^2}dx$$
What you now need to take into account is the direction of the force. This means including a factor of $\cos\theta$:
$$\frac 1 {r^2+x^2}\cos\theta \,dx$$
Since $x=r\tan\theta$, this can be simplified to
$$\frac 1 {r^2+r^2\tan^2\theta}\cos\theta \,dx$$ and thence to $$\frac 1 {r^2\sec^2\theta}\cos\theta \,dx$$
Moreover, since $x=r\tan\theta$, $dx=r\sec^2\theta\,d\theta$. So this simplifies to $$\frac 1 {r^2\sec^2\theta}\cos\theta \,r\sec^2\theta\,d\theta$$ and hence to $$\frac 1 {r}\cos\theta \,d\theta$$
and the integration of that over the range $\theta=-\frac \pi 2$ to $+\frac \pi 2$ (which is to say $x=-\infty$ to $+\infty$ can safely be left as an exercise for the reader.
I have gone into a fair amount of detail here in order to show that deliberately not making obvious substitutions such as $1/\sec^2\theta=\cos^2\theta$ or $\theta=\tan^{-1}\frac x r$ can make the notation simpler and the line of argument easier to follow.
A: Remember that a force is not a scalar quantity, but a vector. So you should include that in your calculation. Notice also that symmetry of a problem could make our life simpler. For E.g. when the particle is placed centrally (the shortest vector connecting the particle and the rod points towards the middle of the rod), which is by the way in the case of an infinite rod, only components perpendicular to the rod play a role while any parallel component is compensated.
