Finding points of maximum or minimum potential energy