On Sat, 9 Aug 2025 at 13:26, Gábor Horváth <hungaborhorv...@gmail.com> wrote: > > So my questions are: > 1) Is the expected behaviour for sympy.solve for the Piecewise case to throw > a NaN comparison exception, or is this a sign of some underlying issue in > sympy.solve for Piecewise functions?
No, that is just a bug. > 2) Is sympy.solve expected to rewrite Min and Max to Piecewise at some point > in the future? I found some piece of code in solvers/solvers.py:944-957 which > does some sort of rewriting for Abs, but didn't find any for Min or Max. It probably does make sense to rewrite Min and Max as Piecewise if they contain the variables of interest. > 3) From some reading on the sympy docs page, I figured solveset is expected > to be the future solver. Is there a direct way I can apply solveset on a > system, rather than on one equation? This documentation needs to be changed. The solveset function is not going to replace solve. It was originally intended as a replacement for solve but was then misdesigned as something different that cannot replace solve because it does not provide comparable functionality or interface. > 4) If the answer to 3) is yes, is there also a way which provides a stable > output that I can use in a programmatic way? Only solve with dict=True gives stable output that is suitable for programmatic use but it is not really designed to handle systems of the type that you have. The solutions to the system x = Max(y, 1), y = Max(2, x) are y = x for x >= 2. Given that the solution set is constrained by an inequality I'm not sure what form of output you would want for programmatic use. It is very difficult to make a solve function that can take arbitrary inputs and give something useful as output, especially handling underdetermined cases, inequality constraints and so on. However if you have a specific class of problems like these with min and max it is a lot easier to make something that handles a more limited case. In this example you can split the equations into 4 linear systems and solve those. In general I think that what you should really want in a situation like this is something like Mathematica's Reduce function rather than Solve. Unfortunately SymPy has several versions of solve but nothing like reduce. -- Oscar -- 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 view this discussion visit https://groups.google.com/d/msgid/sympy/CAHVvXxS2wWOqEUf8Z5h%3DDmGnsYJDhNoag4FCedE8ekJmmWM9Tg%40mail.gmail.com.