On Tue, Sep 9, 2025 at 1:22 PM Gábor Horváth <
hungabo...@gmail.com> wrote:
>
>
> Hi Aaron,
>
> Thank you for the reply, and for the explanation on max behaviour. It
> makes full sense. I guess the interesting part is how much sympy can (or
> does) evaluate >, how much simplification it is willing to do on its own,
> before one needs to specifically ask for it with simplify or doit. I also
> understand to not wanting to do these automatic evaluations as they can be
> expensive. That is fine, but then where was the line drawn on when to
> simplify and when not to?
Right now SymPy doesn't have a clear line which is why it can be slow
sometimes. Ideally the line should be drawn that automatic
simplifications are not done if the require the assumptions system.
>
> I'm not sure I understand why multiple arguments poses a problem. Even in
> the current implementation, the documentation says that Max does
> evaluation on > as much as possible, and return Max(x_1, x_2, ...) where
> x_1, x_2, ... are top elements in the poset defined by the partial
> evaluation of >. The very same thing can be done regardless of how you
> compute the poset of >, the difference is that in case instead of trying
> to evaluate a > b, you do simplify(a-b) > 0, or something like that, then
> your poset of > will possibly contain more comparisons.
OK, so maybe Max is already handling this.
The real issue here is that the logic for this should be handled
separately from Max. The idea place that should be doing this logic is
ask(). But presently ask doesn't do very much with inequalities, which
is a major issue that we want to improve. Really Max() should just be
calling ask(a > b) instead of just checking if a > b auto-evaluates to
True or False. Then inside of ask(), there should be a handler (or a
theory solver, if it's sophisticated enough), that can handle these
kinds of nonlinear inequalities. Presently we only have a theory
solver for handling systems of linear inequalities. This may require
something like the CAD algorithm to handle in full generality,
although there might be simpler algorithms for handling expressions
with only one variable.
Aaron Meurer
> To view this discussion visit
https://groups.google.com/d/msgid/sympy/1948c8be-e4ff-f6f3-36d1-48d5123015eb%40SamsungLaptop.WORKGROUP.