Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
2

Evaluate polynomial expression on matrices

asked 6 years ago

Thrash gravatar image

updated 6 years ago

How can I construct a map M2(Q)3M2(Q),(A,B,C)(ABBA)C where M2(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
Preview: (hide)

Comments

1

Like this:

def f(A,B,C):
        return (A*B-B*A)*C
FrédéricC gravatar imageFrédéricC ( 6 years ago )
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 ( 6 years ago )

Thanks for the clarification!

Thrash gravatar imageThrash ( 6 years ago )

1 Answer

Sort by » oldest newest most voted
3

answered 6 years ago

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})
Preview: (hide)
link

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 ( 6 years ago )

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: 6 years ago

Seen: 396 times

Last updated: Feb 28 '19