PHPSL Function:  Ellipse_Circum( )

  • Ellipse_Circum ($RParam, $rParam)

    Dependencies: NONE


    This function is a high-precision numerical solution to the complete elliptic integral of the second kind which is used here to compute the general circumference or perimeter of an ellipse.

    It was designed primarily for use in geodesy and planetary ellipsoid meridian and elliptical orbital path length computations involving not-too-extreme eccentricities.  For said purposes, the function should converge rapidly to 16 decimals precision.  Internally, arbitrary-precision BC (binary calculator) math is used to preserve accuracy.

    Given an ellipse with parameters $(R, ~ r)$ and $(R ~≥~ r)$:

    • $R ~=~ $Major radius $($semi-major axis$)$ = Maximum parameter

    • $~r ~=~ $Minor radius $($semi-minor axis$)$ = Minimum parameter


    • $~ε ~=~ $Eccentricity of the ellipse

      As a conic section, the eccentricity of an ellipse indicates the degree to which the conic form deviates from a perfect circle.  If $(\epsilon = 0)$, then the conic form equates to the special case of a perfect circle.

      If $(0 ~ < ~\epsilon ~ < ~1)$, then the conic form equates to an ellipse, where $(\epsilon)$ is defined by:


      Eq. $(1):$

      $\large \epsilon = \sqrt{\Large\frac{R^2 ~-~ r^2}{R^2}} ~=~ $ Constant

      and

      Eq. $(2):$

      $\large \epsilon^2 = \Large\frac{R^2 ~-~ r^2}{R^2}$


    The complete elliptic integral of the second kind defines $\frac{1}{4}$ of the circumference of an ellipse.

    Eq. $(3):$
    $ \begin{align*} \frac{C}{4} ~=~ \int_0^{\frac{\pi}{2}}{\sqrt{1-\left(\frac{R^2 ~-~ r^2}{R^2}\right)\cdot sin^2(\phi)}\;\;d\phi} ~=~ \end{align*} $

    We simply multiply the above equation by $4$ to obtain the complete circumference or perimeter of the ellipse.

    Eq. $(4):$
    $ \begin{align*} &C ~=~ 4\cdot \int_0^{\frac{\pi}{2}}{\sqrt{1-\epsilon^2\cdot sin^2(\phi)}\;\;d\phi} \end{align*} ~=~ $


    The above integrals define the problem and the infinite summation below is one among several possible numerical solutions we might apply to evaluate it. 

    Eq. $(5):$
    $ \begin{align*} C ~=~ 2\pi{R}\left[ 1 - \sum_{n=1}^\infty \left(\frac{(2n-1)!!~^2}{(2n)!!~^2\cdot(2n-1)}\right) \cdot \epsilon^{2n}\right] \end{align*} ~=~ $

    This particular summation was chosen primarily because of the relative simplicity of programming it and because it converges to high-precision accuracy sufficiently fast with respect to its intended purposes.

    The following PHP function evaluates the complete elliptic integral of the second kind by evaluating the infinite summation series equation $(5)$ to a precision of $16$ decimals based on the given $(R, ~ r)$ ellipse parameter arguments.

    Double-Click to select ALL code

    Double-Click to select ALL code


    EXAMPLE call results:
    
     print Ellipse_Circum('15', '6');              // =--> 69.0393377869945285
    
    
     print Ellipse_Circum('8.074188', '4.288745'); // =--> 39.7550997002766908
    
    

    Reference:

    http://mathworld.wolfram.com/CompleteEllipticIntegraloftheSecondKind.html

Jay Tanner - 2024