Perimeter of Ellipse
|
06-06-2020, 05:12 PM
(This post was last modified: 06-09-2020 12:55 AM by Albert Chan.)
Post: #24
|
|||
|
|||
RE: Perimeter of Ellipse
Improvement to my previous EK(m)
When m is small, the term E(m) - K(m) is losing significant digits. Worse, catastrophic cancellation occurs at the base of recursion. EKmc(m) returns E(m)-c, K(m)-c, where c=pi/2, similarly to expm1(x) = exp(x) - 1 EK(m) is now a simple wrapper for EKmc(m), adding back the c's. Code: from cmath import sqrt, pi >>> e, k = EK(0.96) >>> 4 * 50 * abs(e) # ellipse_perimeter(10,50), error = 0 ULP 210.10044539689002 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)