Post Reply 
Riemann's Zeta Function - another approach (RPL)
08-05-2017, 04:36 AM (This post was last modified: 08-05-2017 04:37 AM by Gerson W. Barbosa.)
Post: #79
RE: Riemann's Zeta Function - another approach (RPL)
(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
 ...

Code:

 02 X<=0?
 03 X=0?
 04 GTO OO
 ...

Lesson learned, thanks! I knew there was a better way, but I wouldn't remember. In the olden days I had no 41, but I did have a 15C which had all the 12 conditional tests, Gamma, complex mode and a few other thing the 41 lacked :-)



(08-04-2017 07:26 PM)Dieter Wrote:  Edit: here is the current version. It addresses the x~0 problem in a ...err... "creative" way in that the smallest |x| is set to 1E–20. #-)

Please note that this version is intended for high-precision environments like Free42 and may not perform as well on a regular 42s.

Code:
 00 { 416-Byte Prgm }
 01>LBL "ZETA"
 02 0.5
 03 X<>Y
 04 X>=Y?
 05 GTO 77
 06 ABS
 07 1E-20
 08 X<Y?
 09 X<>Y
 10 LASTX
 11 SIGN
 12 ×
 13 1
 14 X<>Y
 15 -
 16 XEQ 77
 17 PI
 18 STO+ ST X
 19 RCL 00
 20 Y^X
 21 ÷
 22 RCL 00
 23 GAMMA
 24 ×
 25 1
 26 ASIN
 27 RCL× 00
 28 COS
 29 ×
 30 STO+ ST X
 31 1
 32 RCL- 00
 33 STO 00
 34 Rv
 35 GTO 99
 36>LBL 77
 37 STO 00
 38 -1
 39 RCL+ 00
 40 1/X
 41 LASTX
 42 X<0?
 43 GTO 97
 44 2
 45 RCL 00
 46 X>Y?
 47 GTO 96
 48 LASTX
 49 LASTX
 50 LASTX
 51 -1.276E-8
 52 ×
 53 7.05133E-6
 54 -
 55 ×
 56 9.721157E-5
 57 +
 58 ×
 59 3.4243368E-4
 60 -
 61 ×
 62 0.00484515482
 63 -
 64 ×
 65 0.07281584288
 66 +
 67 ×
 68 7.215664988E-3
 69 +
 70 GTO 98
 71>LBL 96
 72 100
 73 RCL 00
 74 SQRT
 75 RCL× 00
 76 ÷
 77 5
 78 +
 79 IP
 80 STO+ ST X
 81 STO 01
 82 RCL 00
 83 +/-
 84 STO 00
 85 CLX
 86>LBL 95
 87 RCL ST Y
 88 RCL 00
 89 Y^X
 90 -
 91 +/-
 92 DSE ST Y
 93 GTO 95
 94 RCL 00
 95 STO+ ST X
 96 1
 97 -
 98 RCL 01
 99 X^2
100 24
101 ×
102 ÷
103 1
104 RCL- 00
105 8
106 ÷
107 RCL÷ 01
108 +
109 0.5
110 +
111 RCL+ 01
112 RCL 00
113 Y^X
114 2
115 ÷
116 +
117 1
118 RCL 00
119 +/-
120 STO 00
121 -
122 2
123 LN
124 ×
125 E^X-1
126 +/-
127 ÷
128 4
129 RCL- 00
130 44E-13
131 ×
132 X<0?
133 CLX
134 -
135 GTO 99
136>LBL 97
137 ENTER
138 ENTER
139 ENTER
140 -5.872675E-6
141 ×
142 9.740462E-5
143 +
144 ×
145 3.4213951E-4
146 -
147 ×
148 0.00484515533
149 -
150 ×
151 0.07281584734
152 +
153 ×
154 7.21566494432E-3
155 +
156>LBL 98
157 0.57
158 +
159 X<>Y
160 1/X
161 +
162>LBL 99
163 RCL 00
164 X<>Y
165 .END.

At least the results look quite good. Since x is returned in the upper display line you can see if a value very close to zero has been replaced by 1E–20.

This has replaced what I had in Free42 (per Natural Selection).

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Riemann's Zeta Function - another approach (RPL) - Gerson W. Barbosa - 08-05-2017 04:36 AM



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