pythonmathellipse

How to calculate the perimeter of an ellipse


I want to calculate the perimeter of an ellipse with given values for minor and major axis. I'm currently using Python.

I have calculated the minor axis and major axis lengths for the ellipse i.e. a and b.

It’s easy to calculate the area but I want to calculate the perimeter of the ellipse for calculating a rounded length. Do you have any idea?


Solution

  • According to Ramanujan's first approximation formula of finding perimeter of Ellipse ->

    >>> import math
    >>>
    >>> def calculate_perimeter(a,b):
    ...     perimeter = math.pi * ( 3*(a+b) - math.sqrt( (3*a + b) * (a + 3*b) ) )
    ...     return perimeter
    ...
    >>> calculate_perimeter(2,3)
    15.865437575563961
    

    You can compare the result with google calculator also