(08-04-2017 07:26 PM)Dieter Wrote: [quote='Gerson W. Barbosa' pid='76831' dateline='1501861065']
Back to the HP-41:
Code:
01▸LBL "ZETA"
02 X>0?
03 GTO 00
04 X=0?
05 GTO 00
...
Just one remark: Testing condition1 OR condition2 can be done with a simple trick from the olden days. Simply have the inverse of condition1 followed by condition2.
Code:
01▸LBL "ZETA"
02 X≠0?
03 X>0?
04 GTO 00
...
And the calculation of the number of terms should be replaced by this:
Code:
64▸LBL 96
65 24
66 RCL 00
67 /
68 4
69 +
70 INT
71 ST+ X
72 STO 01
Just for the record, here is the new HP-41 listing with your suggestions:
Code:
01▸LBL "ZETA"
02 X<=0?
03 X=0?
04 GTO 00
05 CHS
06 1
07 +
08 STO 02
09 XEQ "GAMMA"
10 STO 03
11 RCL 02
12 XEQ 00
13 RCL 03
14 *
15 PI
16 ST+ X
17 RCL 02
18 Y^X
19 /
20 1
21 ASIN
22 RCL 02
23 *
24 COS
25 *
26 ST+ X
27 GTO 99
28▸LBL 00
29 STO 00
30 1
31 -
32 1/X
33 LASTX
34 X<0?
35 GTO 97
36 2
37 RCL 00
38 X>Y?
49 GTO 96
40 LASTX
41 LASTX
42 LASTX
43 -1.276E -8
44 *
45 7.05133E -6
46 -
47 *
48 9.721157E -5
49 +
50 *
51 3.4243368E -4
52 -
53 *
54 4.84515482E -3
55 -
56 *
57 7.281584288E -2
58 +
59 *
60 7.215664988E -3
61 +
62 GTO 98
63▸LBL 96
64 24
65 RCL 00
66 /
67 4
68 +
69 INT
70 ST+ X
71 STO 01
72 RCL 00
73 CHS
74 STO 00
75 CLX
76▸LBL 01
77 RCL Y
78 RCL 00
79 Y^X
80 -
81 CHS
82 DSE Y
83 GTO 01
84 RCL 00
85 ST+ X
86 1
87 -
88 RCL 01
89 X^2
90 24
91 *
92 /
93 1
94 RCL 00
95 -
96 8
97 /
98 RCL 01
99 /
100 +
101 .5
102 +
103 RCL 01
104 +
105 RCL 00
106 Y^X
107 2
108 /
109 +
110 1
111 RCL 00
112 +
113 2
114 LN
115 *
116 E^X-1
117 CHS
118 /
119 GTO 99
120▸LBL 97
121 ENTER^
122 ENTER^
123 ENTER^
124 -8.4715E -7
125 *
126 7.51334E -6
127 -
128 *
129 9.609657E -5
130 +
131 *
132 3.42683396E -4
133 -
134 *
135 4.84527616E -3
136 -
137 *
138 7.281583446E -2
139 +
140 *
141 7.215664464E -3
142 +
143▸LBL 98
144 RDN
145 1/X
146 INT
147 ST* Z
148 SIGN
149 STO/ X
150 STO- Z
151 X<> L
152 RDN
153 /
154 -
155 R^
156 .57
157 +
158 +
159▸LBL 99
160 END
The primitive Gamma implementation I've been using is slightly faster:
Code:
01▸LBL "GAMMA"
02 -1
03 X<>Y
04 +
05 1
06 STO 00
07 X>Y?
08 GTO 01
09 ST- L
10 LASTX
11 STO 00
12 INT
13 1
14▸LBL 00
15 RCL 00
16 *
17 DSE 00
18 ABS
19 DSE Y
20 GTO 00
21 STO 00
22▸LBL 01
23 LASTX
24 ENTER^
25 ENTER^
26 ENTER^
27 1.604589926 E-2
28 *
29 2.641400819 E-1
30 -
31 *
32 1.96580515
33 +
34 *
35 8.729327662
36 -
37 *
38 25.69590147
39 +
40 *
41 52.63472435
42 -
43 *
44 76.53826433
45 +
46 *
47 78.92639573
48 -
49 *
50 56.50761084
51 +
52 *
53 26.37243835
54 -
55 *
56 7.203398486
57 +
58 RCL 00
59 *
60 END
And here is the new table:
41 XEQ ZETA --> 1.000000000 ( 8.24 s)
25 R/S --> 1.000000030 ( 8.28 s)
3 R/S --> 1.202056903 (17.89 s)
2.001 R/S --> 1.643997513 (2) (22.33 s)
2 R/S --> 1.644934067 ( 4.04 s)
1.5 R/S --> 2.612375349 ( 4.08 s)
0.5 R/S --> -1.460354509 ( 4.74 s)
0 R/S --> -0.500000000 ( 4.03 s)
-0.5 R/S --> -0.2078862450 (250) ( 9.72 s)
-1 R/S --> -0.08333333384 (33) (10.07 s)
-1.001 R/S --> -0.08316803696 (723) (28.32 s)
-1.5 R/S --> -0.02548520436 (190) (25.38 s)
-2 R/S --> 0.00000000000 (24.84 s)
-3 R/S --> 0.008333333384 (33) (22.09 s)
-5 R/S --> -0.003968253990 (68) (20.24 s)
-7 R/S --> 0.004166666686 (67) (19.39 s)
-15.16 R/S --> 0.4964873534 (85) (18.99 s)
-33.34 R/S --> -1.924684098E10 (152) (22.15 s)
-41.42 R/S --> -3.506595602E16 (584) (24.03 s)
-48.49 R/S --> -3.653091058E22 (22) (25.98 s)
-58.59 R/S --> 1.136304829E32 (792) (28.54 s)
-67.97 R/S --> 1.832460467E40 (1182) (31.02 s)
Times obtained from the HP-41CX built-in stopwatch