Riemann's Zeta Function update (HP-28S, HP-48G/GX/G+, HP-49G/G+/50g)



#2

These are updated versions of the Riemann's Zeta function implementations on the 28 and 48 series RPL calculators described in some recent threads. The HP 50g version, which hasn't undergone any significant change is presented here as a reference. The complex gamma function program for both the HP-28S and HP-48G/GX now uses the Lanczos approximation. The results obtained on these calculators are now very close to those obtained on the hp 50g, for all real and complex arguments.

HP-28S



Zeta:

« RCLF 57 SF 58 SF
36 CF 59 CF SWAP 1
CF DUP RE 0 <
IF
THEN 1 SF NEG 1 +
END DUP 1 - INV
OVER NEG 10 8 0  s
p q n m b
« 0 1 n 1 -
FOR k k q ^ +
NEXT n 1 s - ^ s
1 - / + n q ^ 2 / +
BNL 1 2 m
FOR i s i + 3 -
DUP SQ + p * 'p' STO
GETI p * n 1 i - s -
^ * i FACT / b + 'b'
STO 2
STEP b ROT ROT
DROP2 + 1 FS?
IF
THEN 1 CF RAD 1
s - DUP 2 / ‡ * SIN
OVER DUP IM NOT
« RE DUP 2 MOD
NOT NOT * SIGN NEG *
»
« DROP
» IFTE 2 ROT ^
* * s DUP Gamma ‡
ROT NEG ^ * *
END
» SWAP STOF
»

Gamma:

« 0 { 76.1800917295
-86.5053203294
24.0140982408
-1.23173957245
1.20865097387E-3
-5.39523938495E-6 }
1 6
FOR i DUP i GET 4
PICK i + / ROT +
SWAP
NEXT DROP
1.00000000019 + OVER
/ 2 ‡ * ƒ * SWAP 5.5
+ DUP LN OVER 5 - *
SWAP - EXP *
»

BNL:

{ .166666666667
-3.33333333333E-2
2.38095238095E-2
-3.33333333333E-2
7.57575757576E-2
-.253113553114
1.16666666667
-7.09215686275
54.9711779449
-529.124242424 }

‡: pi
ƒ: sqrt

HP-48G/GX/G+


Zeta:

%%HP: T(3)A(D)F(.);
\<< RCLF { -2 -20 -21
-22 } SF SWAP 1 CF
DUP RE 0 <
IF
THEN 1 SF NEG 1 +
END DUP 1 - INV
OVER NEG 10 8 0 \-> s
p q n m b
\<< 0 1 n 1 -
FOR k k q ^ +
NEXT n 1 s - ^
s 1 - / + n q ^ 2 /
+ BNL 1 2 m
FOR i s i + 3 -
DUP SQ + 'p' STO*
GETI p * n 1 i - s
- ^ * i ! / 'b'
STO+ 2
STEP b ROT ROT
DROP2 + 1 FS?
IF
THEN 1 CF RAD 1
s - DUP 2 / \pi * SIN
OVER DUP IM NOT
\<< RE DUP 2
MOD NOT NOT * SIGN
NEG *
\>>
\<< DROP
\>> IFTE 2 ROT
^ * * s DUP Gamma \pi
ROT NEG ^ * *
END
\>> SWAP STOF
\>>

Gamma:

%%HP: T(3)A(D)F(.);
\<< 0 { 76.1800917295
-86.5053203294
24.0140982408
-1.23173957245
1.20865097387E-3
-5.39523938495E-6 }
1
\<< 3 PICK NSUB + /
+
\>> DOSUBS
1.00000000019 +
OVER / 2 \pi * \v/ *
SWAP 5.5 + DUP LN
OVER 5 - * SWAP -
EXP *
\>>

BNL:

%%HP: T(3)A(D)F(.);
{ .166666666667
-3.33333333333E-2
2.38095238095E-2
-3.33333333333E-2
7.57575757576E-2
-.253113553114
1.16666666667
-7.09215686275
54.9711779449
-529.124242424 }

HP-49G/G+/50g


Zeta:

%%HP: T(3)A(D)F(.);
\<< RCLF { -2. -20. -21. -22. -105. } SF SWAP 1. CF DUP RE 0. <
IF
THEN 1. SF NEG 1. +
END DUP 1. - INV OVER NEG 10. 8. 0. \-> s p q n m b
\<< 0. 1. n 1. -
FOR k k q ^ +
NEXT n 1. s - ^ s 1. - / + n q ^ 2. / + BNL 1. 2. m
FOR i s i + 3. - DUP 1. + * 'p' STO* GETI p * n 1. i - s - ^ * i ! / 'b' STO+ 2.
STEP b NIP NIP + 1. FS?
IF
THEN 1. CF RAD 1. s - DUP 2. / \pi * SIN OVER DUP IM NOT
\<< RE DUP 2. MOD NOT NOT * SIGN NEG *
\>>
\<< DROP
\>> IFTE 2. ROT ^ * * s DUP GAMMA \pi ROT NEG ^ * *
END
\>> SWAP STOF
\>>

BNL:

%%HP: T(3)A(D)F(.);
{ .166666666667 -3.33333333333E-2 2.38095238095E-2 -3.33333333333E-2
7.57575757576E-2 -.253113553114 1.16666666667 -7.09215686275 54.9711779449
-529.124242424 6192.12318841 -86580.2531136 1425517.16667 -27298231.0678
601580873.901 -15116315767.1 429614643062. -1.37116552051E13 4.88332318973E14
-1.92965793419E16 8.41693047575E17 -4.03380718541E19 2.11507486381E21
-1.20866265223E23 7.50086674608E24 }

BNLG:

%%HP: T(3)A(D)F(.);
\<< { } 2. 50.
FOR n n IBERNOULLI \->NUM + 2.
STEP 'BNL' STO
\>>


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP 50g : More on best rechargeable batteries Miguel Toro 1 262 12-12-2013, 05:31 PM
Last Post: David Hayden
  HP50g: Writing a function that returns a function Chris de Castro 2 308 12-10-2013, 06:49 PM
Last Post: Han
  HP-48GX & 50G Question Matt Agajanian 2 273 12-08-2013, 10:17 PM
Last Post: Matt Agajanian
  AFTER HP-Prime update, AA1000 DOES NOT CLEAR THE SPREADSHEET Joseph Ec 0 191 12-06-2013, 11:28 PM
Last Post: Joseph Ec
  AFTER HP-Prime update, AA1000 DOES NOT CLEAR THE SPREADSHED Joseph Ec 0 172 12-06-2013, 12:19 PM
Last Post: Joseph Ec
  AFTER HP-Prime update, Shift+Matrix CRASHES Joseph Ec 3 304 12-06-2013, 11:06 AM
Last Post: Joseph Ec
  I can't update HP Prime JavierLopez 7 480 12-06-2013, 10:37 AM
Last Post: JavierLopez
  HP 50g switching two keys in the user keyboard Sean Freeman 9 575 12-05-2013, 11:44 AM
Last Post: Mark Puscas
  IFERR function on HP Prime Mic 2 269 12-02-2013, 01:33 AM
Last Post: cyrille de Brébisson
  HP 50g - displaying result in engineering format Sean Freeman 10 579 11-24-2013, 05:44 AM
Last Post: C.Ret

Forum Jump: