Monday, January 4, 2010

ZETA IN SCIPY

PROBLEMS WITH ZETA FUNCTION IN SCIPY

Dabbling with zeta in scipy gave various unsatisfactory results. Few very obvious results of zeta function are ;

(1) For negative even integers the function is zero
(2) zeta(0) = -1/2
(3) zeta(-1) = -1/12
(4) zeta(1/2) = -1.46035450880.....
(5) zeta(1) = infinity
(6) zeta(2) = 1.6449340.....

Trying it on scipy,


The probable reason for this inconsistent behaviour and issues for zeta values below 2 and improbable results for negative numbers is; the module is probably structured abinitio from zeta function

whilst it may be a better idea to structure the zeta function using the functional equation.

It may also help to have a special provision for zeta(1/2)

8 comments:

Mike Hansen said...

It looks like mpmath gets them correct:

sage: mpmath.zeta(0.0r)
mpf('-0.5')
sage: mpmath.zeta(-1.0r)
mpf('-0.083333333333333329')
sage: mpmath.zeta(0.5r)
mpf('-1.4603545088095868')
sage: mpmath.zeta(1.0r)
Traceback (most recent call last)
ValueError: zeta(1) pole
sage: mpmath.zeta(2.0r)
mpf('1.6449340668482264')

Anonymous said...

Try using zetac(x) + 1, instead of zeta(x,q). zeta(x,q) returns nan if x < 1.

Also, use 0.5 instead of 1/2, since 1/2 is zero (unless you import division from the future).

Arkapravo Bhaumik said...

Thanks Mike ! ..... mpmath looks great ! .... just that I have not been using it that often ! ..... mpmath is more like MATLAB !

Jason Grout said...

And Sage doesn't do too bad either (I think it uses MPFR behind the scenes):

sage: zeta(0.0)
-0.500000000000000
sage: zeta(-1)
-0.0833333333333333
sage: zeta(0.5)
-1.46035450880959
sage: zeta(1.0)
+infinity
sage: zeta(2.0)
1.64493406684823

Arkapravo Bhaumik said...

Guys !.... many thanks...

mpmath, sage, zetac all work good but I guess that this module zeta(x,q) still needs some improvement !

Anonymous said...

Today is documentation indisposed, isn't it?

Arkapravo Bhaumik said...

Probably ! it has been a while that I worked with zeta or scipy ! It was a glaring error, the scipy community would have corrected it.

bamgosoo said...


Hello, i think that i saw you visited my website thus i came to “return the favor”.
I’m trying to find things to improve my website!I suppose its ok to use some of your ideas!!

Have a look at my homepage; 부산달리기
(jk)