You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The convolution shown below of two piecewise functions appears to result in overlapping cases with varying degrees of severity, depending on the sympy version:
1.7<=1.9 one overlapping case
1.10.1 multiple overlapping case
Code
from sympy import oo, symbols, integrate, Piecewise, Max, Min, pprint
x = symbols("x", real=True)
y = symbols("y", real=True)
f = Piecewise((1/(-Max(0, y) + Min(1, y + 1)), (x <= -Max(0, y)) & (x >= -Min(1, y + 1))), (0, True))
g = Piecewise((1, (x >= 0) & (x <= 1)), (0, True))
tau = symbols('tau', real=True)
pprint(integrate(f.subs(x, tau) * g.subs(x, x - tau), (tau, -oo, +oo)), use_unicode=False)
Output for 1.7<=1.9
Overlapping case y=0 and y ≤ 0.
/ -Max(-1, x - 1) + Max(-1, x - 1, Min(0, x)) for y = 0
|
| Max(-1, x - 1, -y - 1) Max(-1, x - 1, -y - 1, Min(0, x))
|- ---------------------- + --------------------------------- for y <= 0
< y + 1 y + 1
|
| Max(-1, x - 1) Max(-1, x - 1, Min(0, x, -y))
| - -------------- + ----------------------------- otherwise
\ 1 - y 1 - y
Output for 1.10
Multiple cases overlapping at y = 0.
/ -Max(-1, x - 1) + Max(-1, x - 1, Min(0, x)) for y = 0
|
|-Max(-1, x - 1, -y - 1) + Max(-1, x - 1, -y - 1, Min(0, x, -y)) for Or(y = 0, y < 0)
|
| Max(-1, x - 1) Max(-1, x - 1, Min(x, -y))
| - -------------- + -------------------------- for y > 0
| 1 - y 1 - y
<
| Max(-1, x - 1) Max(-1, x - 1, Min(0, x, -y))
| - -------------- + ----------------------------- for y >= 0
| 1 - y 1 - y
|
| Max(-1, x - 1, -y - 1) Max(-1, x - 1, -y - 1, Min(0, x))
| - ---------------------- + --------------------------------- otherwise
\ y + 1 y + 1
The text was updated successfully, but these errors were encountered:
sjtrny
changed the title
Piecewise Convolution Problems
Piecewise Convolution Yields Overlapping Cases
Jul 12, 2022
Also note that SymPy does use overlapping cases, evaluated from top to bottom (note that the last condition is typically True, although printed "Otherwise").
The convolution shown below of two piecewise functions appears to result in overlapping cases with varying degrees of severity, depending on the sympy version:
Code
Output for 1.7<=1.9
Overlapping case
y=0
andy ≤ 0
.Output for 1.10
Multiple cases overlapping at
y = 0
.The text was updated successfully, but these errors were encountered: