The time t and azimuthal angle φ are cyclic coordinates, so that the solution for Hamilton's principal function S can be written where and are the constant generalized momenta. The Hamilton–Jacobi equation gives an integral solution for the radial part Taking the derivative of Hamilton's principal function S with respect to the conserved momentum pφ yields which equals Taking an infinitesimal variation in φ and r yields the fundamental orbital equation where the conserved length-scales a and b are defined by the conserved momenta by the equations Hamilton's principle The action integral for a particle affected only by gravity is where is the proper time and is any smooth parameterization of the particle's world line. If one applies the calculus of variations to this, one again gets the equations for a geodesic. To simplify the calculations, one first takes the variation of the square of the integrand. For the metric and coordinates of this case and assuming that the particle is moving in the equatorial plane , that square is Taking variation of this gives Motion in longitude Vary with respect to longitude only to get Divide by to get the variation of the integrand itself Thus Integrating by parts gives The variation of the longitude is assumed to be zero at the end points, so the first term disappears. The integral can be made nonzero by a perverse choice of unless the other factor inside is zero everywhere. So the equation of motion is Motion in time Vary with respect to time only to get Divide by to get the variation of the integrand itself Thus Integrating by parts gives So the equation of motion is Conserved momenta Integrate these equations of motion to determine the constants of integration getting These two equations for the constants of motion (angular momentum) and (energy) can be combined to form one equation that is true even for photons and other massless particles for which the proper time along a geodesic is zero. Radial motion Substituting and into the metric equation (and using ) gives from which one can derive which is the equation of motion for . The dependence of on can be found by dividing this by to get which is true even for particles without mass. If length scales are defined by and then the dependence of on simplifies to See also Kepler problem Classical central-force problem Two-body problem in