Post Reply 
Riemann's Zeta Function - another approach (RPL)
08-07-2017, 08:52 AM (This post was last modified: 08-08-2017 06:48 PM by Dieter.)
Post: #81
RE: Riemann's Zeta Function - another approach (RPL)
(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. #-)

There is a better solution.

Since \(\zeta '(0) = -\ln\sqrt{2 \pi}\), for x close to zero  \(\zeta(x)\ \approx -(0.5+x\cdot\ln\sqrt{2 \pi})\). So the program may simply switch to this as soon as |x| is sufficiently small. For the given program a good threshold is at 2 E–11. So if |x| is larger than this, use the regular method, and all |x| up to this limit may use the simple formula above. This is what I now have implemented in my Free42 program.

Here is the modified listing. The changes are in the first lines before the XEQ 77 call, and the STO 00 after LBL 77 has been omitted.
Edit: changed the threshold in line 08 from 1E–11 to 2E–11.

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

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

Dieter
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) - Dieter - 08-07-2017 08:52 AM



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