Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to create a matrix valued function?

I'm trying to define a function g that takes two values and maps tem to a 2x2 matrix. What I've tried is

x,y = var('x,y');
g(x,y) = matrix(SR,2,2,[1,x,cos(y),x*y]);

but if I try to evaluate this function, the variables in the matrix are not evaluated:

sage: g(0,0)
[     1      x]
[cos(y)    x*y]

I expect the output to be

[ 1 0]
[ 1 0]

I also tried other variants bud did not succeed, e.g.

  g(x,y) = matrix([[1,x],[x,y]])