(35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
06-27-2021, 08:53 AM (This post was last modified: 06-27-2021 09:06 AM by mchris.)
Post: #1
 mchris Junior Member Posts: 27 Joined: Apr 2020
(35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
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
06-27-2021, 09:07 AM
Post: #2
 mchris Junior Member Posts: 27 Joined: Apr 2020
RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
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
06-27-2021, 02:46 PM
Post: #3
 PedroLeiva Member Posts: 203 Joined: Jun 2014
RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
Just for checking, a numerical example please
Pedro
06-27-2021, 08:15 PM
Post: #4
 mchris Junior Member Posts: 27 Joined: Apr 2020
RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
(06-27-2021 02:46 PM)PedroLeiva Wrote:  Just for checking, a numerical example please
Pedro

06-27-2021, 09:07 PM
Post: #5
 PedroLeiva Member Posts: 203 Joined: Jun 2014
RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
That´s great, Thank you
Pedro
07-03-2021, 08:26 AM (This post was last modified: 07-03-2021 03:47 PM by J-F Garnier.)
Post: #6
 J-F Garnier Senior Member Posts: 745 Joined: Dec 2013
RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
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
07-03-2021, 01:55 PM
Post: #7
 Gerson W. Barbosa Senior Member Posts: 1,487 Joined: Dec 2013
RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
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 …
07-31-2021, 01:36 PM (This post was last modified: 07-31-2021 01:43 PM by dlidstrom.)
Post: #8
 dlidstrom Junior Member Posts: 10 Joined: Jul 2021
RE: (35S) Perimeter of ellipse (Ramanujan 2nd Approximation)
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

HP48GX, HP48GX, 128KB ram card, DM42
 « Next Oldest | Next Newest »

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