Potential Theory in Gravity and Magnetic Applications