Let's say we have some finite mass M of constant density that can be shaped at will. How should we shape it and where do we place it for the gravitational field in some fixed point P to be maximal?

My solution:

Let's say P is the origin of the spherical coordinate system with the force pointing in the pozitive direction of the z-axis.

We must maximize the integral $\displaystyle \int_{\mathcal{V}}{\frac{\cos\theta}{r^2}dm}$, where dm is an infinitesimal element of mass with the integral summing all over the shape of the volume V. If we express dm in spherical coordinates and disregard any constants, we have $\displaystyle \int_{\mathcal{V}}{\cos\theta \sin\theta dr d\theta d\phi}$ for the force at the origin.

The finite mass constraint gives $\displaystyle \int_{\mathcal{V}}{r^2 \sin\theta dr d\theta d\phi}=const.$

How should I proceed?

Thanks