mpmath
mpmath copied to clipboard
Observing very different behaviors between mp.psi and fp.psi
The mp and fp versions of the psi function differ greatly for certain inputs. Here are a few examples that I found of their divergence (starting with one example that behaves as expected but then quickly diverges):
>>> fp.psi(1,-28.3)
15.044694967630004
>>> mp.psi(1,-28.3)
mpf('15.044694967630006')
>>> fp.psi(1,-28.4)
(-0.03459862513722961+0j)
>>> mp.psi(1,-28.4)
mpf('10.876967636294758')
>>> fp.psi(1,-74)
(-0.013422617269905759+0j)
>>> mp.psi(1,-74)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/mpmath/ctx_mp.py", line 267, in psi
return ctx.make_mpf(libmp.mpf_psi(m, z._mpf_, *ctx._prec_rounding))
File "/usr/local/lib/python3.6/dist-packages/mpmath/libmp/gammazeta.py", line 997, in mpf_psi
return mpc_psi(m, (x, fzero), prec, rnd)[0]
File "/usr/local/lib/python3.6/dist-packages/mpmath/libmp/gammazeta.py", line 1023, in mpc_psi
t = mpc_pow_int(z, -m-1, wp)
File "/usr/local/lib/python3.6/dist-packages/mpmath/libmp/libmpc.py", line 258, in mpc_pow_int
return mpf_pow_int(a, n, prec, rnd), fzero
File "/usr/local/lib/python3.6/dist-packages/mpmath/libmp/libmpf.py", line 1073, in mpf_pow_int
return mpf_div(fone, inverse, prec, rnd)
File "/usr/local/lib/python3.6/dist-packages/mpmath/libmp/libmpf.py", line 960, in mpf_div
raise ZeroDivisionError
ZeroDivisionError
>>> fp.psi(1,-74.1)
(-0.013404625024515462+0j)
>>> mp.psi(1,-74.1)
mpf('103.3424344852568')