How can I resolve the equation like x * max(x,15) = 10
with python (maybe Sympy) libraries?
The max()
means the maximum between given two arguments.
My equations has a more complicated form, but I want to resolve it in simplified form.
When I plug your equation into sympy.solve
, it gives NotImplementedError, meaning the algorithms to solve it are not implemented (I opened https://github.com/sympy/sympy/issues/10158 for this).
I think to solve equations like these, you would need to replace each Max
or Min
with its arguments and solve every iteration, and then remove the solutions where the Max
or Min
was not actually maximal or minimal in its argument.
I'll leave the full algorithm to you or some other answerer (or hopefully someone will implement it in SymPy). Some useful tips:
expr.atoms(Max, Min)
will extract all instances of Max
and Min
from expr
.
expr.subs(old, new)
will return a new expression with old
replaced with new
in expr
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With