flintlib / arb

Arb has been merged into FLINT -- use https://github.com/flintlib/flint/ instead
http://arblib.org/
GNU Lesser General Public License v2.1
458 stars 141 forks source link

acb_hypgeom_legendre_p(n, 0, 0) fails with rational n>15 #202

Open rwst opened 6 years ago

rwst commented 6 years ago

With mpmath as comparison:

sage: import mpmath
sage: from sage.libs.mpmath.all import call as mpcall
sage: mpcall(mpmath.legenp, 29/2, 0, 0)
-0.145632776315886
sage: mpcall(mpmath.legenp, 31/2, 0, 0)
0.141013048084263
sage: mpcall(mpmath.legenp, 44/3, 0, 0)
-0.102411166309551
sage: mpcall(mpmath.legenp, 46/3, 0, 0)
0.100234189567193

there is:

sage: CBF(0).legendre_P(29/2)
[-0.14563278 +/- 7.94e-9]
sage: CBF(0).legendre_P(31/2)
nan + nan*I
sage: CBF(0).legendre_P(31/2, 0, type=2)
nan + nan*I
sage: CBF(0).legendre_P(31/2, 0, type=3)
nan + nan*I

sage: CBF(0).legendre_P(44/3)
[-0.102411 +/- 2.40e-7]
sage: CBF(0).legendre_P(46/3)
nan + nan*I

sage: CBF(0).legendre_P(59/4)
[-0.07816789 +/- 7.19e-9]
sage: CBF(0).legendre_P(61/4)
nan + nan*I
fredrik-johansson commented 6 years ago

Increase the precision until the result is sufficiently accurate:

sage: C = ComplexBallField(128)
sage: C(0).legendre_P(31/2)
[0.141013048084263329998974219590 +/- 5.88e-31]
rwst commented 6 years ago

That is unexpected. So this is a Sage interface issue?

fredrik-johansson commented 6 years ago

No, that is how Arb works in general (although the algorithms could be improved to address specific cases like this one). In general the user has the responsibility to check if the interval is precise enough and increase the precision otherwise.