Ask Your Question
2

Evaluate polynomial expression on matrices

asked 2019-02-27 17:04:28 -0500

Thrash gravatar image

updated 2019-02-27 17:15:21 -0500

How can I construct a map $M_2(\mathbb Q)^3 \to M_2(\mathbb Q), (A,B,C) \mapsto (AB-BA)C$ where $M_2(\mathbb Q)$ denotes the space of 2x2 matrices.

sage: x,y,z = var('x y z')
sage: f=(x*y-y*x)*z
sage: f
0
edit retag flag offensive close merge delete

Comments

1

Like this:

def f(A,B,C):
        return (A*B-B*A)*C
FrédéricC gravatar imageFrédéricC ( 2019-02-28 02:07:20 -0500 )edit
1

To further Frederic's answer :

sage: sage: x,y,z = var('x y z')
....: sage: f=(x*y-y*x)*z
....: sage: f
....: 
0
sage: f.parent()
Symbolic Ring
sage: [u.parent() for u in [x,y,z]]
[Symbolic Ring, Symbolic Ring, Symbolic Ring]

This means that f is a symbolic function, whose arguments are symbolic variables. Without further assumptions, Sage will treat the value of f as an expression involving members of the symbolic ring, which is roughly equivalent to treat them as complexes. This implies that multiplication is commutative, hence your result.

Frederic's solution will indeed work, because Sage will not attempt to simplify your code for you, and won't simplify x*y-y*x as 0.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-02-28 03:40:21 -0500 )edit

Thanks for the clarification!

Thrash gravatar imageThrash ( 2019-02-28 11:01:04 -0500 )edit

1 answer

Sort by » oldest newest most voted
3

answered 2019-02-28 04:29:18 -0500

rburing gravatar image

You can define a function as shown in the comments.

Alternatively you can substitute into a noncommutative polynomial, e.g.:

R.<x,y,z> = FreeAlgebra(QQ, 3)
f = (x*y - y*x)*z # not zero
A = Matrix(QQ, [[0,1],[0,0]])
B = Matrix(QQ, [[1,1],[1,1]])
C = Matrix(QQ, [[0,-1],[-1,0]])
f.subs({x: A, y: B, z: C})
edit flag offensive delete link more

Comments

1

Nice ! Didn't think of that...

It turns out that you can even use a "function-call" syntax. With a slight change of notations :

sage: R.<a,b,c> = FreeAlgebra(QQbar, 3)
sage: f=(a*b-b*a)*c
sage: f
a*b*c - b*a*c
sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:A = Matrix(QQ, [[0,1],[0,0]])
:B = Matrix(QQ, [[1,1],[1,1]])
:C = Matrix(QQ, [[0,-1],[-1,0]])
:--
sage: f(A,B,C)
[ 0 -1]
[ 1  0]

which is equivalent (and faster to type) to :

sage: f.subs({a:A, b:B, c:C})
[ 0 -1]
[ 1  0]
Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-02-28 06:25:08 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-02-27 17:04:28 -0500

Seen: 54 times

Last updated: Feb 28