# Evaluate polynomial expression on matrices

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
```

Like this:

To further Frederic's answer :

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 iscommutative, hence your result.Frederic's solution will indeed work, because Sage will

notattempt to simplify your code for you, and won't simplify`x*y-y*x`

as 0.Thanks for the clarification!