symforce icon indicating copy to clipboard operation
symforce copied to clipboard

Fix SymEngine Max derivative

Open aaron-skydio opened this issue 3 years ago • 1 comments

This seems wrong:

sm.Max(x, y).diff(x).subs({x:y})

evaluates to 1/2

Also check in on derivatives of other things we added

aaron-skydio avatar Jan 17 '22 22:01 aaron-skydio

A more concretely wrong example:

In [12]: sm.Max(x, sm.exp(x) - 1, (x + 1)**2 / 2 - sm.S.Half).diff(x).subs(x, 0).evalf()
Out[12]: 1.5

https://www.wolframalpha.com/input?i=Plot%5B%7BMax%5Bx%2C+Exp%5Bx%5D+-+1%2C+%28x%2B1%29%5E2+%2F+2+-+1%2F2%5D%2C+D%5BMax%5Bx%2C+Exp%5Bx%5D+-+1%2C+%28x%2B1%29%5E2+%2F+2+-+1%2F2%5D%2C+x%5D%7D%2C+%7Bx%2C+-1%2C+1%7D%5D

aaron-skydio avatar Jan 18 '23 18:01 aaron-skydio