Post Reply 
Perimeter of Ellipse
04-15-2023, 06:21 PM (This post was last modified: 04-19-2023 09:50 AM by floppy.)
Post: #35
RE: Perimeter of Ellipse
+1.
Now leaving the "simplicity" of having MAGM divided by AGM, at the cost of calculation time, for calculating ellipse perimeter, and lets show what I call "GaussKummer-like" with "AGM functional turbo boosting". If I remember it was already posted in this forum for HP15c. Now for HP41. NO APPROXIMATION: only limitation to the available precision with HP41.

Code:
; calcul ellipse perimeter GaussKummer like with AGM exact function for 
;   "convergence boosting"
;
;Inputs
;  a ENTER b ENTER XEQ PERE12  
;  a and b: half parameter of the ellipse
;
;Outputs
;  results in stack X:perimeter
;
;Modules used
; None
;
;use R 07..11
;keep free Reg 00-06 if use with SOL from MATH from other programs
; in case this program would be used for example for finding the "a" if
; the "perimeter" and the "b" are given
;
;create raw file with "rpncomp --raw-output PERE12.TXT", upload
;  in V41 emulator and store into virtual drive pyILPER
;
;under CC BY SA CreativeCommons 4.0 floppy @ https://www.hpmuseum.org/forum/
;
;idea from here
;        https://www.hpmuseum.org/forum/thread-5820-post-171326.html#pid171326
;
;change log
; date 2023 04 15 creation and release (based on PEREL6 simplified program)
;
;comment
; all an bn R0xn are from the "n" loop
; all with "N" are updated parameter in the new loop
;
LBL "PERE12"              
X=0?         ; in case a = 0 this is a flat ellipse
GTO 01
STO 07       ; b in 07
X<>Y
X=0?         ; in case b = 0 this is a flat ellipse
GTO 01
STO 08       ; a in 08
X^2
X<>Y
X^2
+
STO 09       ; an^2 + bn^2 in R09 
1
STO 10       ; 1 in R10n
;
LBL 00       ;     X             Y          Z          T
  RCL 08     ;     an
  RCL X      ;     an           an
  RCL 07     ;     bn           an          an
  *          ;     bn*an          an
  SQRT       ;  SQRT(an*bn)=bN    an              
  X<> 07     ;     bn             an                
             ;  ... R07 = bN
  RCL 07     ;     bN             bn        an
  X=Y?
  SF 00
  RDN        ;     bn             an       
  -          ;    an-bn           
  2          ;    2            an-bn         
  ST* 10     ;    2            an-bn              
             ;    ... R10N= 2*R10n
  /          ;  (an-bn)/2          
  ST- 08     ;  (an-bn)/2                       
             ;  ... R08N=aN=an-(an-bn)/2=(an+bn)/2
  X^2        ;  ((an-bn)/2)^2     
  RCL 10     ;  R10N      ((an-bn)/2)^2      
  *          ;  R10N*((an-bn)/2)^2           
  ST- 09     ;  R10N*((an-bn)/2)^2             
             ;  ...  R09N = R09n- R10N*((an-bn)/2)^2
  FC?C 00
  GOTO 00
RCL 09
RCL 07 
/
PI
*          
RTN          
LBL 01       ;in case b or a = 0 flat ellipse it goes here out
+
4
*
RTN      
END

Just tested on an HP41CX. Printing w/o comment (in order to see the length).

Code:
 01*LBL "PERE12"
 02 X=0?
 03 GTO 01
 04 STO 07
 05 X<>Y
 06 X=0?
 07 GTO 01
 08 STO 08
 09 X^2
 10 X<>Y
 11 X^2
 12 +
 13 STO 09
 14 1
 15 STO 10
 16*LBL 00
 17 RCL 08
 18 RCL X
 19 RCL 07
 20 STO T
 21 *
 22 SQRT
 23 STO 07
 24 RDN
 25 -
 26 CHS
 27 2
 28 ST* 10
 29 /
 30 ST- 08
 31 X^2
 32 RCL 10
 33 *
 34 ST- 09
 35 RDN
 36 X#Y?
 37 GTO 00
 38 1/X
 39 RCL 09
 40 *
 41 PI
 42 *
 43 RTN
 44*LBL 01
 45 +
 46 4
 47 *
 48 RTN
 49 .END.

Now latest shortest version on HP41 (no check of flat ellipse; no modules required)

Code:
 01*LBL "PERE12"
 02 STO 07
 03 X^2
 04 X<>Y
 05 STO 08
 06 X^2
 07 +
 08 STO 09
 09 1
 10 STO 10
 11*LBL 00
 12 RCL 08
 13 RCL X
 14 RCL 07
 15 STO T
 16 *
 17 SQRT
 18 STO 07
 19 RDN
 20 -
 21 CHS
 22 2
 23 ST* 10
 24 /
 25 ST- 08
 26 X^2
 27 RCL 10
 28 *
 29 ST- 09
 30 RDN
 31 X#Y?
 32 GTO 00
 33 1/X
 34 RCL 09
 35 *
 36 PI
 37 *
 38 RTN
 39 END


Attached File(s)
.txt  PERE12.TXT (Size: 2.34 KB / Downloads: 2)

HP71 4TH/ASM & Multimod, HP41CV/X & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X, HP75D
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Perimeter of Ellipse - Joe Horn - 03-05-2016, 04:19 PM
RE: Perimeter of Ellipse - Wes Loewer - 03-06-2016, 11:55 AM
RE: Perimeter of Ellipse - Wes Loewer - 03-06-2016, 02:16 PM
RE: Perimeter of Ellipse - Joe Horn - 03-07-2016, 03:34 PM
RE: Perimeter of Ellipse - ggauny@live.fr - 07-11-2019, 05:02 PM
RE: Perimeter of Ellipse - TASP - 03-06-2016, 02:40 PM
RE: Perimeter of Ellipse - parisse - 03-06-2016, 06:42 PM
RE: Perimeter of Ellipse - SlideRule - 03-07-2016, 01:16 PM
RE: Perimeter of Ellipse - parisse - 03-09-2016, 08:39 AM
RE: Perimeter of Ellipse - Albert Chan - 03-24-2019, 12:42 PM
RE: Perimeter of Ellipse - Albert Chan - 01-19-2020, 03:56 AM
RE: Perimeter of Ellipse - Albert Chan - 01-19-2020, 11:00 PM
RE: Perimeter of Ellipse - Albert Chan - 01-21-2020, 05:16 PM
RE: Perimeter of Ellipse - Albert Chan - 01-23-2020, 01:40 PM
RE: Perimeter of Ellipse - Albert Chan - 06-05-2020, 03:28 AM
RE: Perimeter of Ellipse - Albert Chan - 08-01-2020, 12:31 PM
RE: Perimeter of Ellipse - Albert Chan - 06-06-2020, 05:12 PM
RE: Perimeter of Ellipse - hazem - 04-11-2023, 09:43 PM
RE: Perimeter of Ellipse - rprosperi - 04-12-2023, 01:53 AM
RE: Perimeter of Ellipse - hazem - 04-13-2023, 02:06 PM
RE: Perimeter of Ellipse - floppy - 04-13-2023, 02:20 PM
RE: Perimeter of Ellipse - Werner - 04-12-2023, 05:43 AM
RE: Perimeter of Ellipse - rprosperi - 04-12-2023, 12:44 PM
RE: Perimeter of Ellipse - floppy - 04-12-2023, 07:22 PM
RE: Perimeter of Ellipse - Albert Chan - 04-13-2023, 05:23 PM
RE: Perimeter of Ellipse - floppy - 04-15-2023 06:21 PM



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