Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3801 by [email protected]: Piecewise integration failure
http://code.google.com/p/sympy/issues/detail?id=3801

I'm trying to obtain symbolic integrals for what I thought to be some rather straightforward piecewise functions.

A very simple case is:

       ⎧0  for t < t₀
       ⎪
f(t) = ⎨x  for t₀ ≤ t
       ⎪
       ⎩0  for t ≥ t₁

Using current git master (1cb25e57), I can obtain an indefinite integral:

In [2]: f = Piecewise((0, t < t0), (x, t0 <= t < t1), (0, t >= t1))

In [3]: integrate(f, t)
Out[3]:
⎧ 0   for t < t₀
⎪
⎨t⋅x  for t₀ ≤ t
⎪
⎩ 0   for t ≥ t₁

However, if I then try to obtain the definite integral over the interval (t0, T), I get an unevaluated integral (and .doit() doesn't help):

In [4]: integrate(f, (t, t0, T))
Out[4]:
T
⌠
⎮  ⎧0  for t < t₀ dt
⎮  ⎪
⎮  ⎨x  for t₀ ≤ t
⎮  ⎪
⎮  ⎩0  for t ≥ t₁
⌡
t₀

Now, I accept this is not as trivial as it looks because sympy doesn't know if t1 > t0 etc. But it seems like there is some understanding of how to deal with that, because if I try the interval (0,1) I get:

ValueError: Called interval evaluation over piecewise function on undefined intervals (0, Min(0, t0)), (Min(1, t0), Min(1, Max(0, t0))), (1, Min(1, Max(0, t1)))

I also tried giving some assumptions:

with assuming(Q.is_true(T > t0), Q.is_true(t1 > t0)):
    pprint(integrate(f, (t, t0, T)))

...but again I get the same result.

Is this a duplicate? I have seen issue 2937, but that is marked as fixed. It refers to issue 2128, but the latest comment there suggests the examples there were fixed in https://github.com/sympy/sympy/pull/1376, except for some evalf problems.

Is there something that makes this example more difficult? Am I missing some way to get the results I want?

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to