Post Reply 
(12C Platinum) Length of An Ellipse
07-23-2019, 05:06 PM (This post was last modified: 07-23-2019 05:35 PM by John Keith.)
Post: #6
RE: (12C Platinum) Length of An Ellipse
I have tried several of these methods and I believe that Ramanujan's approximation is the clear winner. It gives 6 - 9 digits of accuracy for reasonable ellipses and is small and fast. For exact solutions, Albert's AGM2 program is fastest by far, almost 200* as fast as numerical integration on the HP 50! The Gauss-Kummer infinite series (series 2 from the PDF in post #2) looks good but the terms are very slow to compute and the program is large and complicated.

At the risk of trolling this thread I am posting HP-48 versions of the programs for those who may be interested.

Ramanujan:

Code:

\<< DUP2 - ROT ROT + DUP \pi \->NUM * ROT ROT / SQ 3. * 4. OVER - \v/ 10. + / 1. + *
\>>

For the HP 50, ROT ROT can be replaced by UNROT.

AGM2:

Code:

\<< DUP2 SQ SWAP SQ + .5 * .25 0. 0. \-> a b s t k s1
  \<<
    WHILE b a - 'k' STO s t k SQ * - 's1' STO s s1 \=/
    REPEAT a b * \v/ 'b' STO 'a' k .5 * STO+ s1 's' STO t 't' STO+
    END \pi \->NUM 2. * s * k .5 * a + /
  \>>
\>>

This is just a straightforward translation of Albert's Lua code which could be made smaller and faster by moving local variables to the stack at the cost of readability (and effort!).
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C Platinum) Length of An Ellipse - Gamo - 07-07-2019, 05:44 AM
RE: (12C Platinum) Length of An Ellipse - John Keith - 07-23-2019 05:06 PM



User(s) browsing this thread: 1 Guest(s)