### Composition and Matrix Multiplication

The following exercises provide more examples that `AB` = `BA` is generally not true.

Exercise
For each of the following matrix **A**,
find all the matrices **X** satisfying `AX` = `XA`.

1)

Answer No **X** will satisfy `AX` = `XA`
because `AX` and `XA` have different sizes.
Specifically, in order for `AX` to be meaningful, **X** must have two rows.
In order for `XA` to be meaningful **X** must have one column.
Then `AX` is a 1 by 1 matrix, and `XA` is a 2 by 2 matrix.

2)

Answer Similar argument as in the first question shows that **X** must be a 2 by 2 matrix. Let

Then

`AX` = [ |
`x` + `z` |
`y` + `w` |
], `XA` = [ |
`x` + `y` |
`x` - `y` |
] |

`x` - `z` |
`y` - `w` |
`z` + `w` |
`z` - `w` |

so that `AX` = `XA` means

`x` + `z` = `x` + `y`,
`y` + `w` = `x` - `y`,
`x` - `z` = `z` + `w`,
`y` - `w` = `z` - `w`.

The solution is `x` = `w` + 2`z`, `y` = `z`, and `w`, `z` are arbitrary.
In summary, `AX` = `XA` if and only if

**X** = [ |
`w` + 2`z` |
`z` |
] = `w`[ |
1 |
0 |
] + `z`[ |
2 |
1 |
] |

`z` |
`w` |
0 |
1 |
1 |
0 |

3)

Answer Again we assume

and find the condition for `AX` = `XA` to be
`x` = `x`, `y` = 2`y`, 2`z` = `z`, 2`w` = 2`w`.
The solution is `y` = `z` = 0, and `x`, `w` arbitrary.
In other words, **X** is a diagonal matrix.

4)

Answer For any 2 by 2 matrix **X**,
we have `AX` = **O** = `XA` (**O** is the 2 by 2 zero matrix).
Therefore `AX` = `XA` for any **X**.

5)

Answer For any 2 by 2 matrix **X**,
we have `AX` = 2**X** = `XA`.
Therefore `AX` = `XA` for any **X**.

6)

Answer For `AX` and `XA` to be meaningful,
**X** has to be a 3 by 2 matrix.
Then `AX` is a 2 by 2 matrix, `XA` is a 3 by 3 matrix, and they cannot be equal.

Remark Here are some further problems for you to think about.

- If
**A** is not a square matrix, then we can never have `AX` = `XA`
due to the contradiction in size.
- In the 2nd and the 3rd questions, we have seen that two entries in
**X** can be arbitrary.
In the 4th and the 5th questions, all four entries in **X** can be arbitrary.
Can you find examples of 2 by 2 matrix **A**, so that only one entry can be arbitrary?
How about three arbitrary entries, or no arbitrary entries, in **X**?
- What matrix commutes with all the other matrices? In other words,
what
**A** has the property that `AX` = `XA` for all **X**?
First try the 2 by 2 case, and then guess the general case.
- What matrix commutes with all the diagonal matrices? First try the 2 by 2 diagonal matrices
and then the general
`n` by `n` matrices.
- What matrix commutes with all the matrices of the form
**X** = [ |
`w` + 2`z` |
`z` |
] = `w`[ |
1 |
0 |
] + `z`[ |
2 |
1 |
] |

`z` |
`w` |
0 |
1 |
1 |
0 |

We know the matrix **A** in the third problem is one such. The problem is to find all the others.