HP Forums
(35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation) (/thread-17171.html)



(35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - mchris - 06-27-2021 08:53 AM

Put the two radii in X and Y stack and execute. It uses registers A and B
Code:
P001    LBL P
P002    STO B
P003    RDN
P004    STO A
P005    RCL–B
P006    x^2
P007    RCL A
P008    RCL+B
P009    x^2
P010    /
P011    3
P012    *
P013    ENTER
P014    ENTER
P015    4
P016    X<>Y
P017    –
P018    SQRT
P019    10
P020    +
P021    /
P022    1
P023    +
P024    RCL A
P025    RCL+B
P026    *
P027    π
P028    *
P029    RTN



RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - mchris - 06-27-2021 09:07 AM

And if we put the following code to the end we get also the distance of the focal points from the center, on stack Y
Code:
P029    RCL A
P030    X^2
P031    RCL B
P032    X^2
P033    -
P034    ABS
P035    SQRT
P036    X<>Y



RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - PedroLeiva - 06-27-2021 02:46 PM

Just for checking, a numerical example please
Pedro


RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - mchris - 06-27-2021 08:15 PM

(06-27-2021 02:46 PM)PedroLeiva Wrote:  Just for checking, a numerical example please
Pedro

Check this page https://www.mathsisfun.com/geometry/ellipse-perimeter.html


RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - PedroLeiva - 06-27-2021 09:07 PM

That´s great, Thank you
Pedro


RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - J-F Garnier - 07-03-2021 08:26 AM

Here is an alternate version, using no registers, that runs on any scientific RPN machine:

Code:
 01*LBL "P"
 02 +
 03 ENTER^
 04 ENTER^
 05 ENTER^
 06 LASTX
 07 -
 08 LASTX
 09 -
 10 X<>Y
 11 /
 12 X^2
 13 3
 14 *
 15 ENTER^
 16 ENTER^
 17 4
 18 X<>Y
 19 -
 20 SQRT
 21 10
 22 +
 23 /
 24 1
 25 +
 26 *
 27 PI
 28 *
 29 RTN

Example with y=4, x=6:
41C: 31.73087918
32S: 31.7308791784
true: 31.730879178581...

J-F


RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - Gerson W. Barbosa - 07-03-2021 01:55 PM

HP-11C, HP-15C:

Code:

001- LBL D
002- ENTER
003- Rv
004- x<>y
005- -
006- LASTx
007- R^
008- +
009- /
010- LASTx
011- x<>y
012- x^2
013- 3
014- *
015- ABS
016- 4
017- LASTx
018- -
019- SQRT
020- 1
021- 0
022- +
023- +
024- LASTx
025- /
026- *
027- pi
028- *
029- RTN

wp34s:

Code:

0001 LBL A
0002 [<->] XYYZ
0003 STO+ Z
0004 -
0005 RCL/ Y
0006 x[^2]
0007 # 003
0008 [times]
0009 SDR 001
0010 # 004
0011 RCL- L
0012 [sqrt]
0013 SDR 001
0014 INC X
0015 /
0016 INC X
0017 [times]
0018 # [pi]
0019 [times] 
0020 END

or


0015 +
0016 RCL/ L



RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation) - dlidstrom - 07-31-2021 01:36 PM

Here’s a SysRPL implementation using Jazz syntax:

Code:

::
 CK2NOLASTWD
 CK&DISPATCH2
 REALREAL
 ::
  0
  {{ a b h }}
  a b %- DUP %*
  a b %+ DUP %*
  %/ !h
  %PI a b %+ %*
  %1 %3 h %*
  %10 %4 %3 h %* %- %SQRT %+
  %/
  %+
  %*
 ;
;

112.5 bytes
# 9C0Eh