Now, to go to a sphere is trickier, but not too bad with a few tricks. The above equation holds for the force at position z along the axis of a disk, where the disk is assumed to be at z=0. So first off, we have to consider the sphere centered at z=0 and a disk an amount [tex]\xi[/tex] from that. The entire sphere will be many disks displaced by [tex]\xi[/tex] from -r to r, where r is the sphere's radius. The next trick is to ask what the radius of a disk making up the sphere is when it's located at a distance [tex]\xi[/tex] from the center of the sphere. From the formula for a sphere

[tex]R(\xi)=\sqrt{r^2-\xi^2}[/tex].

The next trick is to figure out what z is in terms of [tex]\xi[/tex]. This is fairly easy, since we can take Z to be the distance from the observation point to the sphere's center, and the disk is located a distance [tex]\xi[/tex] from the sphere's center, so

[tex]z(\xi)=Z-\xi[/tex].

Using all this in the above expression for the force due to a disk, we get:

[tex]F=2\pi G\sigma[1-\frac{Z-\xi}{\sqrt{Z^2+r^2-2Z\xi}}][/tex],

where [tex]\sigma[/tex] can now be interpreted as mass density per unit volume. So the trick is taking the integral of this over [tex]\xi[/tex] from -r to r. There are a few tricks to do this^{*}, but if you do it, you come out with

[tex]F=\frac{4\pi G\sigma R^3}{3 Z^2}[/tex],

which is the usual formula for a spherical mass.

*: The trick I used was to realize that I can express [tex]\frac{Z-\xi}{\sqrt{Z^2+r^2-2Z\xi}}=\frac{\partial}{\partial Z}\sqrt{Z^2+r^2-2Z\xi}[/tex] and then integrating by changing variables to [tex]\sqrt{Z^2+r^2-2Z\xi}=x[/tex]. You could also use integration by parts, which takes more steps.