Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify_hypergeometric bug #22467

Closed
rwst opened this issue Feb 28, 2017 · 13 comments
Closed

simplify_hypergeometric bug #22467

rwst opened this issue Feb 28, 2017 · 13 comments

Comments

@rwst
Copy link

rwst commented Feb 28, 2017

The result of expansion of a 2F1 expression using simplify_hypergeometric differs from computing the numeric directly:

sage: hypergeometric((1/5, 4/5), (6/5,), 1/10*sqrt(5)*(sqrt(5) - 1))
hypergeometric((1/5, 4/5), (6/5,), 1/10*sqrt(5)*(sqrt(5) - 1))
sage: _.n()
1.04296605906833
sage: hypergeometric((1/5, 4/5), (6/5,), 1/10*sqrt(5)*(sqrt(5) - 1))
hypergeometric((1/5, 4/5), (6/5,), 1/10*sqrt(5)*(sqrt(5) - 1))
sage: _.simplify_hypergeometric()
0

Inside maxima:

maxima: hgfred([1/5, 4/5], [6/5], 1/10*sqrt(5)*(sqrt(5) - 1));
((1-(sqrt(5)-1)/(2*sqrt(5)))^(1/10)*assoc_legendre_p(-4/5,-1/5,1-(sqrt(5)-1)/sqrt(5))*gamma(1/5))/(5*((sqrt(5)-1)/(2*sqrt(5)))^(1/10))

CC: @slel

Component: calculus

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/22467

@rwst rwst added this to the sage-7.6 milestone Feb 28, 2017
@rwst
Copy link
Author

rwst commented Feb 28, 2017

comment:1

User error. Assumptions given earlier interferred with simplify_hypergemetric.

@rwst rwst removed this from the sage-7.6 milestone Feb 28, 2017
@rwst
Copy link
Author

rwst commented Feb 28, 2017

comment:3

Hijacking ticket to prevent waste. Quite a similar error, this time for real.

@rwst

This comment has been minimized.

@rwst rwst changed the title hypergeometric 2F1 bug simplify_hypergeometric bug Feb 28, 2017
@rwst rwst added this to the sage-7.6 milestone Feb 28, 2017
@rwst

This comment has been minimized.

@fchapoton

This comment has been minimized.

@fchapoton
Copy link
Contributor

comment:6

This is an issue in conversion from maxima:

sage: maxima('((1-(sqrt(5)-1)/(2*sqrt(5)))^(1/10)*assoc_legendre_p(-4/5,-1/5,1-(
....: sqrt(5)-1)/sqrt(5))*gamma(1/5))/(5*((sqrt(5)-1)/(2*sqrt(5)))^(1/10))')
((1-(sqrt(5)-1)/(2*sqrt(5)))^(1/10)*assoc_legendre_p(-4/5,-1/5,1-(sqrt(5)-1)/sqrt(5))*gamma(1/5))/(5*((sqrt(5)-1)/(2*sqrt(5)))^(1/10))
sage: bla=_
sage: bla.sage()
0

@fchapoton
Copy link
Contributor

comment:7

Probably boils down to

sage: maxima('assoc_legendre_p(-4/5,-1/5,1)')
assoc_legendre_p(-4/5,-1/5,1)
sage: _.sage()
0

which in turn comes from

sage: gen_legendre_P(-4/5,-1/5,x)
0

@rwst
Copy link
Author

rwst commented Jan 7, 2018

comment:8

mpmath returns 0.000000000000000 with

        import mpmath
        from sage.libs.mpmath.all import call as mpcall
        mpcall(mpmath.legenp, -0.8, -0.2, 1)

and Wolfram Alpha agrees with it but also agrees with the nonzero value for the 2F1 expression so the simplification by Maxima seems wrong.

On another note there is this in Func_assoc_legendre_P._eval_special_values(self,n,m,x):

        if m > n:
            return ZZ(0)

However in Wikipedia that if |m|>l then Plm=0, so the code seems wrong (missing the abs).

@rwst
Copy link
Author

rwst commented Jan 7, 2018

comment:9

Confirmation from arb:

sage: CBF(1/10*sqrt(5)*(sqrt(5) - 1)).hypergeometric([1/5,4/5],[6/5])
[1.0429660590683 +/- 5.27e-14]
sage: CBF(1).legendre_P(-4/5,-1/5)
0

@fchapoton
Copy link
Contributor

comment:10

Maybe because Legendre polynomials can be extended to rational parameters either by 0 or by hypergeometric functions. What we see looks like a clash of extensions, no ?

@rwst
Copy link
Author

rwst commented Jan 7, 2018

comment:11

No, the relevant extension is http://dlmf.nist.gov/14.3.E6 and it holds for x > 1 but the 2F1 argument here is 0.276 which makes x around 0.447, i.e. < 1. Agree?

@slel
Copy link
Member

slel commented Nov 26, 2021

comment:12

Seems to have been fixed, maybe by #25034
(merged in Sage 9.3.rc5)?

In Sage 9.3 and above:

sage: a = hypergeometric((1/5, 4/5), (6/5,), 1/10*sqrt(5)*(sqrt(5) - 1))
sage: a.n()
1.04296605906833
sage: b = a.simplify_hypergeometric()
sage: b
2/5*5^(19/20)*(1/10)^(9/10)*(-1/10*sqrt(5)*(sqrt(5) - 1)
+ 1)^(1/10)*gamma(1/5)*gen_legendre_P(-4/5, -1/5,
-1/5*sqrt(5)*(sqrt(5) - 1) + 1)/(sqrt(5) - 1)^(1/10)
sage: b.n()
1.04296605906833

@slel slel removed this from the sage-7.6 milestone Nov 26, 2021
@dimpase
Copy link
Member

dimpase commented Nov 27, 2021

Reviewer: Dima Pasechnik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants