Substitution into a derivative

37 views
Skip to first unread message

almog yalin

unread,
Jan 26, 2015, 11:58:10 PM1/26/15
to sy...@googlegroups.com
I'm trying apply the following substitution a(x) = c * b(x) into a'(x)

a = sympy.Function('a')
b
= sympy.Function('b')
c
= sympy.Symbol('c')
x
= sympy.Symbol('x')
expression
= sympy.Derivative(a(x),x)
expression
= expression.subs(a(x),c*b(x))
print expression.simplify()

I was expecting to get
c*Derivative(b(x), x)
but got instead
Derivative(c*b(x), x)
Is there a way to move the coefficient c out of the derivative?

 

Aaron Meurer

unread,
Jan 27, 2015, 12:14:48 PM1/27/15
to sy...@googlegroups.com
Use expression.doit(). simplify() ought to be doing this as well (https://github.com/sympy/sympy/pull/2936 and https://github.com/sympy/sympy/issues/6399).

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/66c991ad-fc06-42f3-b46b-d096826df457%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

almog yalin

unread,
Jan 27, 2015, 1:41:41 PM1/27/15
to sy...@googlegroups.com
That's exactly what I needed. Thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/Foi0UaBCmO0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
Reply all
Reply to author
Forward
0 new messages