Sunday, February 6, 2022

HP 17BII+ and TI-84 Plus CE Python: Zeta Approximation

HP 17BII+ and TI-84 Plus CE Python:  Zeta Approximation


Zeta Function


zeta(x) = Σ(1 ÷ (n^x), n =1 to ∞)


We are going to use the approximation:


zeta(x) = Σ(1 ÷ (n^x), n =1 to w) where w = intg(10^((a + 2) ÷ x)


where a is the number of decimal places desired.  The higher the accuracy, the longer the calculation takes.  Also the lower x is, the longer the calculation takes.


This is for all x > 0.


HP 17BII+ Formula ZETA


ZETA=0×L(W:10^IP((ACC+2)÷X))+Σ(N:1:G(W):1:INV(N^X))


Examples:


ACC =3, X = 2;  Result:  ZETA = 1.63


ACC =3, X = 3.5;  Result:  ZETA = 1.13


ACC =3, X = 8.7;  Result:  ZETA = 1.00


TI-84 Plus CE Python:  zeta.py


# 2021-12-07 ews

# zeta function approximation

from math import *

print("zeta function approximation")

x=eval(input("x? "))

a=eval(input("# places? "))

w=int(10**((a+2)/x)

z=0

n=1

while n<w:

  z+=(n**x)**-1

  n+=1

z=round(z,a)

print("zeta = "+str(z))


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Sharp EL-9300 Programs

Sharp EL-9300 Programs Today’s blog entry takes us to the 1992 Sharp’s EL-9300 graphing calculator. On January 10, 2022, I gave a revi...