# Matrices $M$ and $N$ with $MN\neq NM$.

Matrices $M=\begin{pmatrix}-0.6&0.8\\0.8&0.6\end{pmatrix}$ and $N=\begin{pmatrix}0.8&0.6\\0.6&-0.8\end{pmatrix}$ represent $y = 2x$ and $3y = x$, respectively. Verify that $MN$ is not equal to $NM$, and explain why this should have been expected.

What transformations do the two products represent?

I tried multiplying and finding the products of $MN$ and $NM$, but when I calculated them, they seemed to be equal. I got \begin{pmatrix}-0.48& 0.48\\ 0.48& -0.48\end{pmatrix} both times.

Am I doing something wrong?

• $\left(\matrix{a & b \\ c & d}\right)$ gives $\left(\matrix{a & b \\ c & d}\right)$. You can edit your question here. – Arnaud Mortier Aug 17 '18 at 5:24
• @ArnaudMortier You can get the same result shorter with pmatrix like this: $\pmatrix{ a & b \\ c & d }$ → $\pmatrix{ a & b \\ c & d }$ – CiaPan Aug 17 '18 at 5:29
• It looks like you're multiplying the matrices wrong. Matrix multiplication is not element wise, like how you seem to be doing it. – Sriram Gopalakrishnan Aug 17 '18 at 5:33
• What do you mean they represent $y=2x$ and $3y=x$? And yes, I agree with Sriram. Recheck the definition of matrix multiplication. – zahbaz Aug 17 '18 at 5:42

Yes, you are doing something wrong. But it is hard to tell, when you do not show your calculation.

For example when we calculate $MN$.

Then:

$\begin{pmatrix}-0.6&0.8\\0.8&0.6\end{pmatrix}\cdot \begin{pmatrix}0.8&0.6\\0.6&-0.8\end{pmatrix}=\begin{pmatrix} (-0.6)\cdot 0.8+0.6\cdot 0.8& (-0.6)\cdot 0.6+0.8\cdot (-0.8)\\0.8\cdot 0.8+0.6\cdot 0.6&0.8\cdot 0.6+0.6\cdot (-0.8)\end{pmatrix}=\begin{pmatrix}0&-1\\1&0\end{pmatrix}$

Similar you calculate $NM$.

Take a point $(1,1)$ and multiply by the matrices: $$\begin{pmatrix}1&1\end{pmatrix}\begin{pmatrix}-0.6&0.8\\0.8&0.6\end{pmatrix}=\begin{pmatrix}0.2&1.4\end{pmatrix} \ \ \ \ \ \ \text{(M is reflecting the point via y=2x)};\\ \begin{pmatrix}1&1\end{pmatrix}\begin{pmatrix}0.8&0.6\\0.6&-0.8\end{pmatrix}=\begin{pmatrix}1.4&-0.2\end{pmatrix} \ \ \ \ \ \ \text{(N is reflecting the point via y=\frac{x}{3})};\\ \begin{pmatrix}1&1\end{pmatrix}\begin{pmatrix}-0.6&0.8\\0.8&0.6\end{pmatrix}\begin{pmatrix}0.8&0.6\\0.6&-0.8\end{pmatrix}=\begin{pmatrix}1&1\end{pmatrix}\begin{pmatrix}0&-1\\1&0\end{pmatrix}=\\ =\begin{pmatrix}1&-1\end{pmatrix} \ \ \ \ \ \ \text{(MN is reflecting the point via x-axis)};\\ \begin{pmatrix}1&1\end{pmatrix}\begin{pmatrix}0.8&0.6\\0.6&-0.8\end{pmatrix}\begin{pmatrix}-0.6&0.8\\0.8&0.6\end{pmatrix}=\begin{pmatrix}1&1\end{pmatrix}\begin{pmatrix}0&1\\-1&0\end{pmatrix}=\\ =\begin{pmatrix}-1&1\end{pmatrix} \ \ \ \ \ \ \text{(NM is reflecting the point via y-axis)}.$$

First off, matrix multiplication is not simply multiplying term wise. Here, what you did, is said that $$\begin{bmatrix} a_{11}&a_{12} \\ a_{21}&a_{22} \end{bmatrix} \begin{bmatrix} b_{11}&b_{12} \\ b_{21}&b_{22} \end{bmatrix} = \begin{bmatrix} a_{11}b_{11}&a_{12}b_{12} \\ a_{21}b_{21}&a_{22}b_{22} \end{bmatrix}$$ which is not right.

It should really be $$\begin{bmatrix} a_{11}&a_{12} \\ a_{21}&a_{22} \end{bmatrix} \begin{bmatrix} b_{11}&b_{12} \\ b_{21}&b_{22} \end{bmatrix} = \begin{bmatrix} a_{11}b_{11}+a_{12}b_{21}&a_{11}b_{12}+a_{12}b_{22} \\ a_{21}b_{11}+a_{22}b_{21}&a_{21}b_{12}+a_{22}b_{22} \end{bmatrix}$$

As has been calculated above in another answer, one gets with $MN$ ... \begin{bmatrix} 0&-1 \\ 1&0 \end{bmatrix}

and with $NM$... $$\begin{bmatrix} 0&1\\ -1&0\\ \end{bmatrix}$$, so $MN \neq MN$.

Now, I think the bigger problem is making sense of matrix multiplication.

Now, you may wonder, why is THIS the way we multiply matrices? While the way you multiplied might make the most 'sense' in terms of computation when you think about matrices, in terms of structure and linear maps, the bottom definition is far superior, because it represents the combination of two linear maps. Here is a nice way to think about matrix multiplication. As you should probably know, a linear map just maps a vector space to another, linearly. A matrix represents a linear map with respect to a given basis, the matrix \begin{bmatrix} a_{11}&a_{12} \\ a_{21}&a_{22} \end{bmatrix} and a vector $b=[b_1 \, \, b_2]$, that we can write $b$ in terms of basis vectors $e_1$ and $e_2$, so that we write for some values $v_1$ and $v_2$, $b=e_1v_1 + e_2v_2$. A linear transformation, $f$ of this, one finds $f(b) = v_1f(e_1)+v_2f(e_2)$. Now, clearly, since $f$ brings a vector to a vector, we can write, with $f()_{x}$ the $x$th element of the vector... $$\left\{ \begin{array}{c} f(b)_{1}&=v_1f(e_1)_{1}+v_2f(e_2)_{1}\\ f(b)_{2}&=v_1f(e_1)_{2}+v_2f(e_2)_{2} \end{array} \right.$$

Notice something familiar? Let us take $e_1=[1 \, \, 0]$ and $e_2=[0 \, \, 1]$, the standard basis vectors as they are called. Let us represent $f(e_m)_n$ as $A_{nm}$. The 'swap' in indices is just notation.

From this, we declare the matrix $A= \begin{bmatrix} a_{11}&a_{12} \\ a_{21}&a_{22} \end{bmatrix}$

Now, when we compose two linear maps, we do this two times. That is, I have a matrix, $A$, take a vector, $v$, to an new vector, $w$. I then take this vector, $w$ using $B$, to once again a new vector, $u$. Then, $u=B(Av)$. We define the value $C=AB$ to be the matrix such that $u=Cv$. You can think of this as associativity of mappings.

Actually calculating it out, one finds $$\begin{bmatrix} a_{11}&a_{12} \\ a_{21}&a_{22} \end{bmatrix} \left( \begin{bmatrix} b_{11}&b_{12} \\ b_{21}&b_{22} \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} \right) = \begin{bmatrix} a_{11}&a_{12} \\ a_{21}&a_{22} \end{bmatrix} \begin{bmatrix} b_{11}v_1+b_{12}v_2 \\ b_{21}v_1+b_{22}v_2 \end{bmatrix} = \begin{bmatrix} (a_{11}b_{11}+a_{12}b_{21})v_1+(a_{11}b_{12}+a_{12}b_{22})v_2 \\ (a_{21}b_{11}+a_{22}b_{21})v_1+(a_{21}b_{12}+a_{22}b_{22})v_2 \end{bmatrix}$$ We can 'factor out' these terms and find that $$AB=\begin{bmatrix} a_{11}b_{11}+a_{12}b_{21}&a_{11}b_{12}+a_{12}b_{22} \\ a_{21}b_{11}+a_{22}b_{21}&a_{21}b_{12}+a_{22}b_{22} \end{bmatrix}$$.

Or, another way of seeing this is that by definition of the matrix, the first column represents the transformed basis vector, which we in turn transform again, so 'singling out' this vector and transforming it normally will be like tipping the $m$th column of the right matrix into the $n$th row of the left matrix, and doing the 'linear calculation'(matching first with first, second with second and adding), to get the $nm$th index.

Can you see, why, in general, this is not commutative? Just try swapping around the a's and b's and you will find that in the top left, since in general, $a_{12} \neq a_{21}$, so the top left clearly isn't commutative and so neither the whole matrix.