9
$\begingroup$

In Mathematica 12.0.0.0 when I input one of these:

Log[2/Im[ZetaZero[127]]]

Log[2/Im[ZetaZero[128]]]

Log[2/Im[ZetaZero[127]]]//N

Log[2/Im[ZetaZero[128]]]//N

notebook keeps running unevaluated forever. Notice that 127-th zeta zero is the first zero that violates the Gram's law (Gram points). So I guess this fact could have something to do with this bug. Log[2/Im[ZetaZero[129]]] is evaluated correctly.

Can you reproduce the bug? Is it the same with newer versions of Mathematica?

EDIT:

Better way to reproduce the bug:

Evaluate it on a fresh kernel - quit kernel, then type something simple like 2+2 to restart kernel and then type the code

Table[Log[Im[ZetaZero[n + 1]]/Im[ZetaZero[n]]], {n, 1, 128}] // N

It will keep running forever.

$\endgroup$
8
  • $\begingroup$ It evaluates instantly in "12.3.1 for Microsoft Windows (64-bit) (June 24, 2021)" to $-4.95041$ and $-4.95305$. $\endgroup$
    – Domen
    Sep 17 at 19:57
  • $\begingroup$ Can you evaluate Table[Log[Im[ZetaZero[n + 1]]/Im[ZetaZero[n]]], {n, 1, 128}] // N. How long does it take on your version? $\endgroup$ Sep 17 at 20:00
  • $\begingroup$ Evaluate it on a fresh kernel. Qiut kernel, then type something simple like 2+2 to restart kernel and then type the code with the table I posted above. $\endgroup$ Sep 17 at 20:05
  • 1
    $\begingroup$ When I tried it before, it took 13 seconds on the first run and 6 seconds for subsequent runs (probably because of some internal caching). However, on a fresh kernel, it does seem to get stuck! $\endgroup$
    – Domen
    Sep 17 at 20:11
  • 1
    $\begingroup$ I'm able to reproduce the hanging Table call in V12.3. $\endgroup$
    – Chip Hurst
    Sep 18 at 0:36
17
$\begingroup$

Workaround:

This issue seems to be related to caching of previous numerical values. If we clear the cache during each iteration we get a result back:

Table[
  ClearSystemCache["Numeric"]; 
  N[Log[Im[ZetaZero[n + 1]]/Im[ZetaZero[n]]]], 
  {n, 1, 128}
]; // AbsoluteTiming
{6.8104, Null}

What to do

Report this to WRI.

It's strange that N[ZetaZero[128]] works, but iterating up to it in a Table breaks it.

Diagnosis:

After some investigation through GeneralUtilities`PrintDefinitions it seems we're getting stuck in an infinite While loop in System`FunctionZerosDump`NZetaZeroApprox.

The While loop is towards the bottom of the definition:

enter image description here

In our case, m == 4969178850004113/17592186044416, p == ∞, and hence eps = 0.

This makes our While loop spin forever, continually multiplying 2*0.

Offending call:

The offending call is

System`FunctionZerosDump`NZetaZeroApprox[127, {∞, 16.255619765854984`}]

where p above is from System`FunctionZerosDump`NZetaZeroApprox[k, {p, a}].

Changing p to something like 100 gives us a result.

Looking through NValues for ZetaZero, the only way p could be is if we make the call N[ZetaZero[127], {∞, a}] -- which we are not.

$\endgroup$
1
  • $\begingroup$ Thanks for detailed analysis. This bug persists in Mathematica from earlier versions. It was version 7 or 8 if I remember correctly when I started to use Mathematica, and the bug was already there. I even think that I reported this bug a long time ago but nothing happened. At least now I know how to avoid the bug - precompute values of required zeros and then use them instead of using ZetaZero. $\endgroup$ Sep 18 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.