| 1 | initial version |
The problem arises from the fact that matrices with symbolic expressions are not "symbolic expressions" themselves:
sage: B = matrix([[u(k),v(q)],[v(q),u(k)]])
sage: type(B)
sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense
sage: type(u)
sage.symbolic.function_factory.NewSymbolicFunction
sage: type(u(q))
sage.symbolic.expression.Expression
and hence, trying to turn it into a CallableSymbolicExpression by itself fails.
Possibly the easiest thing is to just live with B. You can still substitute values, as long as you're explicit about the substitutions:
sage: B(k=17,q=sin(q))
[ u(17) v(sin(q))]
[v(sin(q)) u(17)]
The nice thing is that you can do matrix algebra with these:
sage: H=B(k=k,q=q)*B(k=q,q=q)
sage: H
[ u(k)*u(q) + v(q)^2 u(k)*v(q) + u(q)*v(q)]
[u(k)*v(q) + u(q)*v(q) u(k)*u(q) + v(q)^2]
sage: H(k=sin(17),q=pi)
[ u(pi)*u(sin(17)) + v(pi)^2 u(pi)*v(pi) + u(sin(17))*v(pi)]
[u(pi)*v(pi) + u(sin(17))*v(pi) u(pi)*u(sin(17)) + v(pi)^2]
Presently, "callable" symbolic expressions and "symbolic" matrices are two extensions built on top of symbolic expressions and they don't mix very well.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.