Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifying Piecewise when two cases have same value #8458

Closed
cbm755 opened this issue Nov 16, 2014 · 1 comment · Fixed by #15898
Closed

Simplifying Piecewise when two cases have same value #8458

cbm755 opened this issue Nov 16, 2014 · 1 comment · Fixed by #15898

Comments

@cbm755
Copy link
Contributor

cbm755 commented Nov 16, 2014

In [92]: Piecewise((0, Eq(x, 0)), (sin(x), True))
Out[92]: Piecewise((0, x == 0), (sin(x), True))

In [93]: pprint(_)
⎧  0     for x = 0
⎨                 
⎩sin(x)  otherwise

In [94]: simplify(_)
Out[94]: Piecewise((0, x == 0), (sin(x), True))

Perhaps this should not happen automatically, but it would be nice if simplify() did it. Apologies if this is a dupe, didn't see it. Figure its related to #1009 somehow.


Very simple cases work:

In [97]: Piecewise((10, Eq(x,0)), (10, True))
Out[97]: 10

And some more complicated things work too:

In [101]: p3 = Piecewise((10, Eq(x, 0)), (y, True))

In [101]: p3
Out[101]: Piecewise((10, x == 0), (y, True))

In [102]: p3.subs(y,10)
Out[102]: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants