I want to replace a derivative by a symbol.
In some cases it works:
In [1]: from sympy import *
In [2]: x = Function('x')
In [3]: f = Function('f')
In [4]: a = Symbol('a')
In [5]: t = Symbol('t')
In [6]: term = 5+x(t).diff(t)
In [9]: term.subs(x(t).diff(t), a)
Out[9]: 5 + a
But what I really want to do is:
In [17]: f(x(t)).diff(t)
Out[17]: D(f(x(t)), x(t))*D(x(t), t)
In [18]: term = f(x(t)).diff(t)
In [19]: term.subs(x(t).diff(t), a)
-> ValueError: Invalid literal: x(t) is not a valid variable
My desired result would be:
a*D(f(x(t)), x(t))
I tested it with the current master branch.
After playing around I think the term D(f(x(t)), x(t)) is the problem
because if I do
In [54]: ( Derivative(f(x(t)), x(t))*a )
Out[54]: a*D(f(x(t)), x(t))
In [55]: ( Derivative(f(x(t)), x(t))*a ).subs(a, 5)
the same error occurs.
With my limited insight I would guess that in
sympy/core/function.py(623) the argument **{'evaluate': True} causes
this behavior.
Do I use something wrong?
What would be another way to achieve the desired result?
Thanks,
Bastian.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.