From d2346f8a4051151d28447474f3435149ad6b82d1 Mon Sep 17 00:00:00 2001 From: ashviz915 <154710760+avyukth-fll@users.noreply.github.com> Date: Tue, 21 Oct 2025 23:59:13 -0700 Subject: [PATCH] Ellipse perimeter calculation Updated the perimeter calculation for Ellipse using Ramanujan's approximation, which is more accurate --- geometry/geometry.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/geometry/geometry.py b/geometry/geometry.py index a0be8eb3befc..6ea7b94d171c 100644 --- a/geometry/geometry.py +++ b/geometry/geometry.py @@ -103,9 +103,11 @@ def area(self) -> float: def perimeter(self) -> float: """ >>> Ellipse(5, 10).perimeter - 47.12388980384689 + 48.44222344723793 """ - return math.pi * (self.major_radius + self.minor_radius) + a, b = self.major_radius, self.minor_radius + #uses ramanujans approximation + return math.pi * (3*(a + b) - ((3*a + b)*(a + 3*b))**0.5) class Circle(Ellipse):