Is there a way to collect derivatives w.r.t. the same symbol in a sum?
There are several questions that go around this point, but I haven’t found an answer for the simple situation:
from sympy import *
x,y,z,t = symbols('x y z t')
expr = z * (Derivative(x,t) + Derivative(y,t))
expr
'z*(Derivative(x, t) + Derivative(y, t))'
expr.simplify(doit=False)
'z*(Derivative(x, t) + Derivative(y, t))'
I would expect to get
'z*Derivative(x+y, t)'
I have tried using the replace
function to substitute derivation with multiplication, but going back is not really working due to the factor z
being reorganized, or simplification functions failing to handle non-commutative symbols.