-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPEREL4.TXT
135 lines (135 loc) · 2.7 KB
/
PEREL4.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
LBL "PEREL4" ;calculus of ellipse perimeter acc Cayley infinite series
;
;Input
; a ENTER b ENTER n XEQ PEREL4
; 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
;
;R 07-19 are used (R00-06 used by SOL of MATH)
;R16 not used; optimization possible
;
;from http://www.numericana.com/answer/ellipse.htm#elliptic
;under CC BY SA creative commons 4.0 pascaldagornet at yahoo dot de
;
;create raw file with "hp41uc.exe /t=PEREL4.TXT /r /k"
; and upload in Emulator V41 and transfer to pyILPER virtual drive
; use in HP41 hardware by connecting a PC via pilbox
;
;change log
;2021 09 07 ; freed Reg 00-06 for use with SOL from MATH
;2021 10 14 Update header/comments
;2021 10 19 DSE introduced
;
;
;
CF 00 ;flag 00 will show the exit criter of precision limit achieved
1000
*
STO 18 ;n entry in 18 maximum iterations
RDN
X>Y?
X<>Y
X=0? ;in case a = 0 this is a flat ellipse
GTO 04
STO 07 ;b in 07
X<>Y
STO 08 ;a in 08 and now is a bigger than b
/
X^2
STO 09 ;x help parameter which is (b/a)^2
1/x
16
*
LN
1
-
STO 10 ;y help variable
RCL 09
4
/
STO 11 ;t help variable
*
STO 13 ;u help variable
1
STO 19 ;m as countup in 19 (n entry in 18)
STO 15 ;w help variable
0.5
STO 14 ;v help variable
0
STO 12 ;p help variable
STO 17 ;p1 help variable
LBL 01 ;main iteration loop
RCL 13
ST+ 12
1
ST+ 19
RCL 14
RCL 09
*
ST* 11
RCL 19
0.5
-
RCL 19
/
STO 14
ST* 11
RCL 15
ST- 10
RCL 19
0.5
-
RCL 19
*
1/X
0.5
*
STO 15
ST- 10
RCL 10
RCL 11
*
STO 13
RCL 12
+
STO 17
DSE 18 ;maximum iteration achieved then stop calculating
GTO 03
GTO 02 ;n is max iterations in 1000 to avoid unstable exit criteria
LBL 03
RCL 17
RCL 12
X<>Y? ;no difference of series increase in 1 iteration
GTO 06
FS? 00
GTO 02 ;previous iter was outside cal tolerance, then exit
SF 00
GTO 01
LBL 02 ;final normal exit calculation
CF 00
RCL 12
1
+
RCL 08
*
4
* ;perimeter in X
RCL 19 ;iterations done in Y
X<>Y
RCL 17
RCL 12
-
X<>Y ;precision in Z
RTN
LBL 04 ;in case b = 0 it goes here
X<>Y
4
*
RTN
LBL 06 ;in case increment not 0. makes 0 seen in 2 consecutive iterations
CF 00
GTO 01
END