Distribute derivative of sum with constant term after substitution

23 views
Skip to first unread message

Carl Sandrock

unread,
Sep 3, 2015, 1:54:54 AM9/3/15
to sympy

If I do

import sympy
k, V, Vprime = sympy.symbols('k, V, Vprime')

print sympy.diff(k + V(t), t)

I get Derivative(V(t), t) as I expect - the derivative distributes and the constant term has zero derivative.

However, if I construct an equivalent expression via substitution, simplify does not distribute the derivative. How can I get the same result via substitution as when I evaluate the expression directly?

sympy.diff(Vprime(t)).subs({Vprime(t): k + V(t)}).simplify()

returns Derivative(k + V(t), t).


(also posted on Stackoverflow


Kalevi Suominen

unread,
Sep 3, 2015, 3:18:35 AM9/3/15
to sympy
Perhaps you could use ``doit()``` instead of ``simplify()``.

 


Carl Sandrock

unread,
Sep 3, 2015, 6:02:34 AM9/3/15
to sympy
That worked perfectly, thank you very much! 
Reply all
Reply to author
Forward
0 new messages