Reputation: 613
In the following example I substitute a function into a matrix expression. I expect some simplifications after the .doit() call:
x = symbols('x', real=True)
f = symbols('f', real=True)(x)
v = Matrix([f * sin(x), f * cos(x)])
v1 = v.diff(x)
print v1.subs(f, x)
# prints: Matrix([[x*cos(x) + sin(x)*Derivative(x, x)], [-x*sin(x) + cos(x)*Derivative(x, x)]])
print v1.subs(f, x).doit()
# prints: Matrix([[x*cos(x) + sin(x)*Derivative(x, x)], [-x*sin(x) + cos(x)*Derivative(x, x)]])
print Matrix([e.doit() for e in v1.subs(f, x)])
# prints: Matrix([[x*cos(x) + sin(x)], [-x*sin(x) + cos(x)]])
But it doesn't happen. If I call .doit() for each element of matrix, everything works correct.
Question: What is incorrect, my code or behaviour of the .doit() function? How to fix it?
Upvotes: 2
Views: 116
Reputation: 91620
It seems this has been fixed in the development version of SymPy. A new version (1.0) should be released sometime soon.
Upvotes: 1