HP Forums
(DM42) (Free42) Riemann Zeta function for complex variables - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (DM42) (Free42) Riemann Zeta function for complex variables (/thread-19794.html)



(DM42) (Free42) Riemann Zeta function for complex variables - Gjermund Skailand - 04-10-2023 04:17 PM

minor update
Riemann Zeta function for DM42, Free42
Real or complex input, accuracy 30-32 digits
Zeta(s)=Zeta(x+iy)
Uses reflection formula for input with real part less than 1
Note that Zeta(1) is not defined.(or infinity if you like)
Uses "Borwein method(2)"
Runs in 4stk mode, using local vaiables N,d,r,s, requires function "Gamma" included in raw file.

for real values: Accuracy of 30-32 digits.
for imaginary values y: The method is slow, since required iterations incerases with about 0.9*Y.
Might not be that important if using Free42...
If you do not require full accuracy, at line 16, change from 44 to 16 will give 11-12 correct digits
some exact values as examples for calibration
Zeta(2)= (pi^2)/6
Zeta(10)=(pi^10)/93555
Zeta(-13)= -1/12
No exact values for complex input, but compare accuracy to wolframalpha:

Zeta(2.5+i3.3), in 0.28 seconds on DM42 on USB power -->
0.8517959540094586535483446233861111 -i0.06816865625500691866043404518227872

For complex values, use e.g. http://www.wolframalpha.com Zeta function
Zeta(2.5 +i3.3) =
0.8517959540094586535483446233861100 -0.06816865625500691866043404518227873 i


Zeta(2.5+i3.3), reduced accuracy in 0.10 seconds on DM42 on USB power -->
0.85179595401 -i0.06816865626 (fix 11)

2023-04-10 skai new version
Code:

00 { 220-Byte Prgm }
01▸LBL "Zeta" @ Riemann Zeta, complex accuracy 30-32 digits 
02 FUNC 11    @ uses Borwein (2)
03 L4STK      @ local variables N,d,r,s, requires function "Gamma"
04 RAD        @ skai 2023-04-10
05 LSTO "s"
06 ENTER
07 REAL?
08 0
09 CPX?
10 RCOMPLX
11 X≠0?
12 GTO 09
13 X≠Y?
14 GTO 09
15 -0.5        @ Zeta(0)= -0.5
16 RTN
17▸LBL 09
18 ABS
19 0.9
20 ×
21 IP
22 44
23 +
24 LSTO "N"
25 1
26 LSTO "r"
27 X≤? ST Z
28 GTO 05
29 R↑
30 -
31 STO "s"
32 DUP
33 XEQ "Gamma"
34 PI
35 2
36 ×
37 R↑
38 +/-
39 Y↑X
40 STO+ ST X
41 ×
42 PI
43 2
44 ÷
45 R↑
46 ×
47 COS
48 ×
49 STO "r"
50▸LBL 05
51 RCL "N"
52 1
53 +
54 LASTX
55 NEWMAT
56 EDIT
57 CLST
58▸LBL 00
59 RCL "N"
60 RCL+ ST Z
61 RCL ST Z
62 STO+ ST X
63 COMB
64 2
65 R↑
66 Y↑X
67 LASTX
68 R↓
69 X↑2
70 ×
71 RCL "N"
72 ×
73 R↑
74 RCL+ ST L
75 ÷
76 +
77 STOEL
78 ISG ST Y
79 NOP
80 J+
81 FC? 77
82 GTO 00
83 RCLEL
84 EXITALL
85 X<>Y
86 LSTO "d"
87 -
88 EDIT
89 CLST
90▸LBL 02
91 X<>Y
92 SIGN
93 RCL+ ST L
94 +/-
95 X<>Y
96 RCL ST Y
97 ABS
98 RCL "s"
99 Y↑X
100 RCLEL
101 X<>Y
102 ÷
103 0>? ST Z
104 +/-
105 +
106 I+
107 FC? 77
108 GTO 02
109 RCLEL
110 EXITALL
111 R↓
112 RCL÷ "d"
113 1
114 2
115 1
116 RCL- "s"
117 Y↑X
118 -
119 ÷
120 RCL× "r"
121 END
brgds
Gjermund