Sympy generating broken `Piecewise` conditions when simplifying
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2
--
Chapters
00:00 Question
02:31 Accepted answer (Score 1)
03:16 Thank you
--
Full question
https://stackoverflow.com/questions/5328...
Question links:
[the SymPy issue tracker]: https://github.com/sympy/sympy/issues
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #sympy
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2
--
Chapters
00:00 Question
02:31 Accepted answer (Score 1)
03:16 Thank you
--
Full question
https://stackoverflow.com/questions/5328...
Question links:
[the SymPy issue tracker]: https://github.com/sympy/sympy/issues
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #sympy
#avk47
ACCEPTED ANSWER
Score 1
The output is not "broken" or "nonsensical". It is logically correct, although not presented in the simplest form possible.
The condition if n == 3 and n != 0 could be simplified to if n == 3. There is a difference between "could be simplified" and "is completely nonsensical".
But yes, please report it on SymPy tracker, since the simplification is incomplete; a better result would be Piecewise((0, Ne(n, 3)), (-1.0, True)).