The problem is, as I noted, you are using NumPy arrays to store SymPy
expressions instead of using SymPy matrices. NumPy arrays do not
define * as matrix multiplication like sympy matrix does, but rather
as elementwise multiplication with broadcasting. It's generally a good
idea to use @ for matrix multiplication instead of *, but even so, you
wouldn't have this issue if you used only SymPy matrices because
SymPy's Matrix does define * as matrix multiplication.
I would recommend not mixing NumPy and SymPy like this. You should do
symbolic operations using only SymPy and SymPy classes. If you want to
use NumPy to do numeric calculations on these expressions, this should
be done explicitly at the end after converting your SymPy expression
into a NumPy function using lambdify().
Aaron Meurer
> To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/d060941d-279b-4763-b7c1-4d0482f39589n%40googlegroups.com.