On Friday, April 28, 2017 at 7:41:47 AM UTC+3, chaowen guo wrote:
>
> Hi:
>
> import sympy
> x=sympy.symbols('x',real=True)
> sympy.integrate(sympy.Heaviside(x-1)*(x-1)+1,(x,0,2))
>
> the output is 2, which is wrong, the correct answer is 5/2
>
> I try the following Mathematica code:
>
> Integrate[HeavisideTheta[x - 1]*(x - 1) + 1, {x, 0, 2}] which gives me 5/2
>
> also the following piecewise function:
>
> sympy.integrate(sympy.Piecewise((1,x<1),(x,x>1)),(x,0,2)) which gives me 
> the correct answer
>
> So I want to ask whether it is a bug in Heaviside function or there are 
> some special explanations in sympy?
>

The indefinite integral involves a Meijer G-function that SymPy is unable 
to evaluate.

>  >>> integrate(Heaviside(x-1)*(x-1) + 1, x)
> x + Piecewise((0, Abs(x) < 1), (meijerg(((3, 1), ()), ((), (1, 0)), x), 
> True))
>
>  Manual integration will give the correct answer:

> >>> integrate(Heaviside(x-1)*(x-1) + 1, (x, 0, 2), manual=True)
> 5/2
>

So the bug is in the evaluation of the indefinite integral.

Kalevi Suominen 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/d3738997-9b1d-41b4-b261-4a953333dc17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to