math.CA — Classical Analysis and ODEs
Improved approximations for the perimeter of an ellipse
We give three closed formulas, with three, four and six square roots, for the perimeter of an ellipse with semi-axes . In exact arithmetic their maximum relative errors over all eccentricities, , and , lie below the unit roundoff of single, double and quadruple precision, respectively, and evaluated in that precision they are accurate to within about six units of it (for quadruple precision, as estimated with -digit decimal arithmetic). Each formula writes a fixed number of steps of the arithmetic--geometric mean (AGM) as one expression, in a form that avoids the harmful cancellation. For flat ellipses, where any fixed number of AGM steps eventually fails (as it tends to instead of ), it switches to an approximation based on Legendre's relation, which expresses the complete elliptic integral of the second kind exactly through the integral of the first kind and two power series in : the AGM steps supply an estimate of , and the series are truncated to short polynomials. A final term makes the formula continuous at the switch, and we give the range of its coefficient that suffices for each precision. We prove that for every switch point and every accuracy there are such continuous formulas, and that the error of the continuous formula is at most that of the AGM branch plus twice that of the flat-ellipse branch. The formulas are exact at and at ; numerically, they are increasing in and more accurate than Ramanujan's second approximation at every eccentricity, by factors of at least , and . With the latency of three, four or six AGM steps, they are faster than an AGM loop of the same accuracy for flat ellipses, where the loop needs more steps. We also study nested-radical generalisations of Ramanujan's second approximation, with and a constant plus nested square roots of a polynomial in . Ramanujan's formula is a degenerate member of a one-parameter family of double-nested forms that agree with the Gauss--Kummer series through . We derive double- and triple-nested formulas with integer coefficients and double-, triple- and quadruple-nested formulas with real coefficients: formulas that are, as verified numerically, nowhere less accurate than Ramanujan's, formulas that agree with the series to the highest order possible for their depth, and minimax formulas. The best of them reduce the maximum error of Ramanujan's formula by up to five orders of magnitude. We also give a numerically stable evaluation in powers of , tabulate the errors of all formulas at seven eccentricities where the perimeter has a closed form, and compare their cost with that of the AGM in double and single precision.