symforce
symforce copied to clipboard
Fix SymEngine Max derivative
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
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