question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: zeta(1/2, 1) returns nan

See original GitHub issue

Describe your issue.

The Hurwitz zeta function at 1/2, 1 is equivalent to Riemann zeta function at 1/2 and so zeta(1/2, 1) = zeta(1/2) = -1.46... (See WolframAlpha) but scipy.special.zeta returns nan. This may be expected behavior but if so it would be nice to have documentation for this behavior.

Related issue: https://github.com/pytorch/pytorch/issues/68110

Reproducing Code Example

from scipy.special import zeta

# correct
output = zeta(1 / 2)
print(output)

# wrong
output = zeta(1 / 2, 1)
print(output)

Error message

-1.4603545088095866            
nan

SciPy/NumPy/Python version information

1.7.1 1.21.2 sys.version_info(major=3, minor=9, micro=8, releaselevel=‘final’, serial=0)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
simakicommented, Nov 20, 2021

Thank you!

In my understanding, while the original definition of Hurwitz zeta zeta(s,a) only works for Re(s)>1 as you pointed out, one would be able to further define it for s!=1 through analytic continuation (cf https://dlmf.nist.gov/25.11). So zeta(s,1)=zeta(s) would hold for s!=1.

On the other hand I personally presume even if the statement above is mathematically true the implementation for Re(s)<1 may not be really necessary for a moment because its use case would be rare. Actually I just happened to find it when I was examining https://github.com/pytorch/pytorch/issues/68110

0reactions
Gattocruccocommented, Jul 27, 2022

Right now I need special.zeta(s, a) with negative s. I’m using the one from JAX which implements it. Edit: JAX supports only s > 1 too (https://github.com/google/jax/issues/11521). The function is meromorphic, so it’s well defined, there are no branch cuts, and it’s real for real arguments.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Round NaN in Haskell - floating point - Stack Overflow
If we check for NaN , we can return any value, but then our property ... NaN is represented as the emax+1, as...
Read more >
error while writing variable: zeta - Ocean Modeling Discussion
1 ntsAVG Starting timestep for the accumulation of output time-averaged data. ... 1.0000E-12 gls_Pmin GLS minimum value of dissipation.
Read more >
SIMULATION ERROR - OVERFLOW - isec.nacse.org • View topic
This is the expression ( zeta(i,j,n+1,cur_level).ne.zeta(i,j,n+1 ... in the domain one of the physical variables (free surface or velocity) has become NaN.
Read more >
"Problem whit initial parameters" in bayesian fitting - Misc. - Pyro ...
After run, this error appears “Cannot find valid initial parameters. Please check your model again.” I tried to look for answers in the...
Read more >
3D half-space simulation in C++ scuff-em returns NAN output · Issue ...
I am trying to compute (electric) Greens function (say Gzz with r= r') for the half-space geometry using scuff-em C++ library. However, I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found