### Composition and Matrix Multiplication

Exercise What are the matrices **A** satisfying
`AX` = `XA` for any **X**?
Answer If **A** is an `m` by `n` matrix,
then in order for both `AX` and `XA` to make sense,
**X** has to be an `n` by `m` matrix. Then `AX` is an
`m` by `m` matrix, and `XA` is an `n` by `n` matrix.
Now for the two matrix to be equal, we must have `m` = `n`. In other words,
**A** has to be a square matrix.

Now assume **A** is an `n` by `n` matrix. Let **E**_{ij}
be the `n` by `n` matrix with 1 as the `ij`-entry and 0 as all the other entries.
For example, in case `n` = 3 we have

**E**_{11} = [ |
1 |
0 |
0 |
], **E**_{23} = [ |
0 |
0 |
0 |
], **E**_{31} = [ |
0 |
0 |
0 |
] |

0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |

0 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |

Then **AE**_{ij} is obtained by moving the `i`-th column of
**A** to `j`-th column, and leaving all the other columns zero. For example,

`AE`_{23} = [ |
`a`_{11} |
`a`_{12} |
`a`_{13} |
] [ |
0 |
0 |
0 |
] = [ |
0 |
0 |
`a`_{12} |
] |

`a`_{21} |
`a`_{22} |
`a`_{23} |
0 |
0 |
1 |
0 |
0 |
`a`_{22} |

`a`_{31} |
`a`_{32} |
`a`_{33} |
0 |
0 |
0 |
0 |
0 |
`a`_{32} |

And **E**_{ij}**A** is obtained by moving the `j`-th row of
**A** to `i`-th row, and leaving all the other rows zero. For example,

**E**_{23}**A** = [ |
0 |
0 |
0 |
] [ |
`a`_{11} |
`a`_{12} |
`a`_{13} |
] = [ |
0 |
0 |
0 |
] |

0 |
0 |
1 |
`a`_{21} |
`a`_{22} |
`a`_{23} |
`a`_{31} |
`a`_{32} |
`a`_{33} |

0 |
0 |
0 |
`a`_{31} |
`a`_{32} |
`a`_{33} |
0 |
0 |
0 |

Thus from **AE**_{ij} = **E**_{ij}**A**, we have

- Any entry of
**AE**_{ij} not in the `i`-th row should vanish.
This means in the `i`-th column of **A**, all but `a`_{ii}
should vanish. In the **E**_{23} example above, we mean
`a`_{12} = `a`_{32} = 0.
- Any entry of
**E**_{ij}**A** not in the `j`-th column should vanish.
This means in the `j`-th row of **A**, all but `a`_{jj}
should vanish. In the **E**_{23} example above, we mean
`a`_{31} = `a`_{32} = 0.
- The
`ij`-entry of **AE**_{ij} and **E**_{ij}**A**
are equal. This means that `a`_{ii} = `a`_{jj}.

Since the above should hold for any `i`, `j`, we conclude that
`a`_{ij} = 0 for `i` ≠ `j`, and
`a`_{ii} = `a`_{jj} for any `i`, `j`.
This is the same as **A** = `a`**I**, which is a constant multiple of the identity.