I have the following:
x,x1,x2,t=symbols('x x1 x2 t')
f=t*x1*x2*(x-t)**(-0.5)
integrate(f,t)
I can integrate with respect to x
, x1
and x2
, but when I try to integrate with respect to t
(which is what I want) I get the following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/sympy/integrals/integrals.py", line 1295, in integrate
risch=risch, manual=manual)
File "/usr/local/lib/python2.7/dist-packages/sympy/integrals/integrals.py", line 486, in doit
conds=conds)
File "/usr/local/lib/python2.7/dist-packages/sympy/integrals/integrals.py", line 908, in _eval_integral
h = meijerint_indefinite(g, x)
File "/usr/local/lib/python2.7/dist-packages/sympy/integrals/meijerint.py", line 1612, in meijerint_indefinite
res = _meijerint_indefinite_1(f.subs(x, x + a), x)
File "/usr/local/lib/python2.7/dist-packages/sympy/integrals/meijerint.py", line 1677, in _meijerint_indefinite_1
r = hyperexpand(r.subs(t, a*x**b), place=place)
File "/usr/local/lib/python2.7/dist-packages/sympy/simplify/hyperexpand.py", line 2473, in hyperexpand
return f.replace(hyper, do_replace).replace(meijerg, do_meijer)
File "/usr/local/lib/python2.7/dist-packages/sympy/core/basic.py", line 1408, in replace
rv = bottom_up(self, rec_replace, atoms=True)
File "/usr/local/lib/python2.7/dist-packages/sympy/simplify/simplify.py", line 999, in bottom_up
rv = F(rv)
File "/usr/local/lib/python2.7/dist-packages/sympy/core/basic.py", line 1393, in rec_replace
new = _value(expr, result)
File "/usr/local/lib/python2.7/dist-packages/sympy/core/basic.py", line 1336, in <lambda>
_value = lambda expr, result: value(*expr.args)
File "/usr/local/lib/python2.7/dist-packages/sympy/simplify/hyperexpand.py", line 2470, in do_meijer
allow_hyper, rewrite=rewrite, place=place)
File "/usr/local/lib/python2.7/dist-packages/sympy/simplify/hyperexpand.py", line 2355, in _meijergexpand
t, 1/z0)
File "/usr/local/lib/python2.7/dist-packages/sympy/simplify/hyperexpand.py", line 2281, in do_slater
t, premult, bh, rewrite=None)
File "/usr/local/lib/python2.7/dist-packages/sympy/simplify/hyperexpand.py", line 2038, in _hyperexpand
ops += devise_plan(func, formula.func, z0)
File "/usr/local/lib/python2.7/dist-packages/sympy/simplify/hyperexpand.py", line 1615, in devise_plan
raise ValueError('Non-suitable parameters.')
ValueError: Non-suitable parameters.
What does this error mean?
Many of SymPy's routines struggle to handle floating point numbers, especially in exponents. Use rational numbers whenever possible. More discussion in common gotchas and pitfalls .
>>> x,x1,x2,t=symbols('x x1 x2 t')
>>> f=t*x1*x2*(x-t)**(-Rational('0.5'))
>>> integrate(f,t).simplify()
Piecewise((2*sqrt(x)*x1*x2*(-I*t**2*sqrt((t - x)/x) - I*t*x*sqrt((t - x)/x) + 2*t*x + 2*I*x**2*sqrt((t - x)/x) - 2*x**2)/(3*(t - x)), Abs(t/x) > 1), (2*sqrt(x)*x1*x2*(-t**2*sqrt((-t + x)/x) - t*x*sqrt((-t + x)/x) + 2*t*x + 2*x**2*sqrt((-t + x)/x) - 2*x**2)/(3*(t - x)), True))
Not the nicest answer, but it's an answer. If you know that x and t are, say, positive, it might help in simplification to declare it as such from the beginning. There are also two cases depending on Abs(t/x)
being greater than 1 or not.
Ways to create the rational exponent 1/2:
Rational(1, 2)
Rational('0.5')
S(1)/2
sqrt
function, which has the same effect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.