conds='none' in Sympy does not work

≯℡__Kan透↙ 提交于 2020-01-05 04:32:06

问题


I have the following integral

x,x1,x2,t=symbols('x x1 x2 t')
f=t*x1*x2*(x-t)**(-Rational('0.5'))
integrate(f,t).simplify()

The result of this is a piecewise function

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))

I want to ignore the first case, so the solution would be to do

integrate(f,t,conds='none').simplify()

But this doesn't change the output, which is still

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))

How can I ignore the conditions then?


回答1:


I think the reason that conds does not affect this integral is that the conditions are not convergence conditions, but rather conditions that affect the form of the integrand. The documentation of conds specifically refers to conditions for convergence.

Definite improper integrals often entail delicate convergence conditions. Pass conds=’piecewise’, ‘separate’ or ‘none’ to have these returned, respectively, as a Piecewise function, as a separate result (i.e. result will be a tuple), or not at all (default is ‘piecewise’).

You can get rid of the case you don't want by replacing its condition with False.

>>> integrate(f, t).subs(Abs(t/x)>1, False).simplify()
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))


来源:https://stackoverflow.com/questions/49183749/conds-none-in-sympy-does-not-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!