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
Add support for the derivative of the max function #1960
Comments
I am not sure I understand what the |
the symengine offer the operator max class Max : public MultiArgFunction
{
public:
IMPLEMENT_TYPEID(SYMENGINE_MAX)
//! Max Constructor
Max(const vec_basic &&arg);
//! \return `true` if canonical
bool is_canonical(const vec_basic &arg) const;
//! \return canonicalized Max
virtual RCP<const Basic> create(const vec_basic &arg) const;
};
//! Canonicalize Max:
RCP<const Basic> max(const vec_basic &arg); the function is like |
i find there is a piecewise function |
It seems as if derivatives of the Using sympy we get: import sympy
x = sympy.Symbol('x')
f1 = x
f2 = x**2
expr = sympy.Max(f1, f2)
sympy.diff(expr, x)
Out[10]:
2*x*Heaviside(x**2 - x) + Heaviside(-x**2 + x) where if using symengine we get the unevaluated expression back The alternative to using the step function would be to use So to implement this in symengine first an implementation of the heaviside function is needed and then an entry in the derivative visitor for the max function. |
i want to simplify a long expression by vairable substitution, and the expression has a Derivative operator, like
when i set a map
and execute the subs.
Then the term
Derivative(max(f1, f2), x) = 0
, and the whole expression collapseSo i find that the vairable substitution cut off the relation between the experssion and the variables
my question is how to deal with the operator Derivative when taking variable substitution,
can i remove it when there is an operator max?
or can i keep it when execute the variable substitution?
The text was updated successfully, but these errors were encountered: