-
Notifications
You must be signed in to change notification settings - Fork 0
/
PEREL3.TXT
111 lines (111 loc) · 2.21 KB
/
PEREL3.TXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
LBL "PEREL3" ;calcul ellipse perimeter according GaussKummer
;Input
; a ENTER b ENTER n XEQ PEREL3
; a and b: half parameter of the ellipse
; n is max iter in 1000 to avoid unstable exit criteria
;Output
; in stack X:perimeter Y:HP41 precision achieved
; Z:number of iterations
;
;use R 07-15 (R00-06 used by SOL of MATH)
;
;under CC BY SA CreativeCommons 4.0 pascaldagornet at yahoo dot de
;basic calculation from
; http://www.numericana.com/answer/ellipse.htm#elliptic
;
;change log
;date 2021 10 06; update comments + compatibility NutStudio
;date 2021 10 14: update header/comments
;date 2021 10 19 implement DSE
;
;
CF 00 ;flag 00 will show the exit criteria of precision limit of the HP41
1000
*
STO 09 ;R09 max number of iterations countdown
STO 15 ;R15 max number of iterations initial
RDN
X>Y?
X<>Y
X=0? ;in case of flat ellipse
GTO 04
STO 07 ;b in 07
X<>Y
STO 08 ;a in 08 and now is a bigger than b
X<>Y
-
LASTX
RCL 08
+
/
STO 10
.5
*
STO 11
X^2
1
+
STO 12
1
STO 13
LBL 01 ;main loop
RCL 13
ST* 11
3
+
ST/ 11
RCL 10
ST* 11
RCL 12
STO 14
RCL 11
X^2
ST+ 12
2
ST+ 13
;
;1
;ST- 09
;RCL 09
;X=0? ;countdown from *1000 reached is an exit criteria (better use DSG?)
;
DSE 09
GTO 03
GTO 02
LBL 03
RCL 14
RCL 12
X!=Y? ;NutStudio dont like X<>Y?
GTO 06 ;an increment different from 0? then clear the flag if already set
FS? 00 ;previous iteration had already achieved the max cal precision?
GTO 02 ;lets go out
SF 00 ;iteration identified an increment of 0 (=max precision achieved)
GTO 01 ;main loop again
LBL 02 ;out label
CF 00
RCL 07
RCL 08
+
RCL 12
*
PI
*
RCL 15
RCL 09
- ;will place in the stack the number of done iterations
X<>Y
RCL 14
RCL 12
- ;will place in the stack the precision achieved
;(in case stopped by iterations)
X<>Y
RTN
LBL 04 ;in case of a flat ellipse
X<>Y
4
*
RTN
LBL 06
CF 00
GTO 01
END