Open DouisLavid opened 7 months ago
I will share what I have found out.
I don't know if this is the cause of all the issues, but it seems that meijerint_indefinite
is not working as it is supposed to.
When calculating sp.Integral(z**(x+sp.Rational(1,2)-1)*(1-z)**(sp.Rational(3,2)-1), (z, 0, 1))
, it computes the following
i = meijerint_indefinite(z**(x - Rational(1, 2))*sqrt(1 - z), z)
i.subs(z,1) - i.subs(z,0)
Now, if we look at the internals of meijerint_indefinite
, it stores the results in results
and eventually returns one of them.
In this example, we get two results, one of which gives us the correct answer, but actually returns the wrong one.
from sympy import *
from sympy.integrals.meijerint import _meijerint_indefinite_1, _find_splitting_points, _has
def meijerint_indefinite_part(f, x):
""" part of meijerint_indefinite
"""
f = sympify(f)
results = []
for a in sorted(_find_splitting_points(f, x) | {S.Zero}, key=default_sort_key):
res = _meijerint_indefinite_1(f.subs(x, x + a), x)
if not res:
continue
res = res.subs(x, x - a)
if _has(res, hyper, meijerg):
results.append(res)
else:
return res
return results
# return next(ordered(results))
x = Symbol("x", positive=True)
y = Symbol("y", positive=True)
z = Symbol("z", real=True)
i = meijerint_indefinite_part(z**(x - Rational(1, 2))*sqrt(1 - z), z)
(i[0].subs(z,1) - i[0].subs(z,0)).simplify() # sqrt(pi)*gamma(x + 1/2)/(2*gamma(x + 2)) # correct
(i[1].subs(z,1) - i[1].subs(z,0)).simplify() # -sqrt(pi)*gamma(x + 1/2)/(2*gamma(x + 2)) # bad
It seems that when computing the result of integrals that derive from the beta function, some unexpected factors appear :
Notice that using a particular value for y can yield results that are not consistent with the previous calculation :