Ask Your Question

flawr's profile - activity

2023-12-06 01:32:45 +0200 received badge  Famous Question (source)
2021-06-24 22:52:13 +0200 received badge  Notable Question (source)
2019-12-12 17:45:27 +0200 received badge  Popular Question (source)
2017-11-16 17:01:17 +0200 received badge  Student (source)
2017-11-16 16:55:51 +0200 asked a question 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]])