Skip to content

Commit d562bdc

Browse files
Fix unit test for ellipse perimeter calculation
Added clarification comment for the approximation used.
1 parent f681f44 commit d562bdc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

geometry/geometry.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ def area(self) -> float:
103103
def perimeter(self) -> float:
104104
"""
105105
>>> Ellipse(5, 10).perimeter
106-
48.44222344723793
106+
48.44210548835644
107107
"""
108108
a, b = self.major_radius, self.minor_radius
109-
# uses ramanujans approximation
109+
# Use Ramanujan's first approximation for ellipse perimeter
110+
# https://en.wikipedia.org/wiki/Perimeter_of_an_ellipse#First_approximation
110111
return math.pi * (3 * (a + b) - ((3 * a + b) * (a + 3 * b)) ** 0.5)
111112

112113

0 commit comments

Comments
 (0)