# Matrix transform- about origin, then angular rotation

#### Jundoe

##### New member
The problem asks to find the standard matrix for the composition of these two linear operations on R2.
- A reflection about the line y=x, followed by a rotation counterclockwise of 60o.

This is how I proceeded.

y=x

$\begin{bmatrix}0&1\\1&0 \end{bmatrix}$

counter clockwise 60degs.

$\begin{bmatrix}1/2&-sqrt(3)/2\\sqrt(3)/2&1/2 \end{bmatrix}$

...then I multiplied them. Causing a dilemma. What order?

$\begin{bmatrix}0&1\\1&0 \end{bmatrix}$$\begin{bmatrix}1/2&-sqrt(3)/2\\sqrt(3)/2&1/2 \end{bmatrix} yields \begin{bmatrix}sqrt(3)/2&1/2\\1/2&-sqrt(3)/2 \end{bmatrix} The reverse obviously gave me a different answer, but I couldn't really visualize it. \begin{bmatrix}1/2&-sqrt(3)/2\\sqrt(3)/2&1/2 \end{bmatrix}$$\begin{bmatrix}0&1\\1&0 \end{bmatrix}$

Was my initial step correct?

#### Ackbach

##### Indicium Physicus
Staff member
The reflection matrix should be on the right, since it will "hit" the vector-to-be-transformed first. Remember: operators (matrices) only look to the right.

#### Jundoe

##### New member
Remember: operators (matrices) only look to the right.
This is clear. But I fail to understand why it would need to be reflected first before being rotated. (Note that I'm visualizing this with a paper as an object, and my desk as the space). If I draw an imaginary x=y line and rotate it before I reflect it, I feel like the outcome would be the same...?

Again, I am not debating this matter, as I am sure you are right. But I'm just having a hard time visualizing it.

Thank you.

[edit.] I am in an intro to Lin.Algebra class. If the explanation for this is beyond the beginner's scope, let me know. Several explanations have been omitted by our professor because he stated that certain things can *eventually be understood with practice, instead the application is prime in this course.
So if "reflection before rotation" is something i should just accept for the moment, do let me know. Last edited:

#### Ackbach

##### Indicium Physicus
Staff member
No, you can rotate before reflection. However, your particular problem stated that the reflection was followed by the rotation. You can do operations in any order you want; however, if the problem statement asks for a particular order, you'd better follow that order!

Reversing the operations does not, in general, produce the same result, particularly in 3D.

#### Deveno

##### Well-known member
MHB Math Scholar
One way to prove the order of the composition matters is to pick a particular point in the plane, and compare the results of doing it "both ways".

So let's start with the point $(x,y) = (\frac{\sqrt{3}}{2},\frac{1}{2})$.

Note that this is just the intersection of the line (well, "ray" actually) at an angle of 30 degrees with the $x$-axis, and the unit circle.

If we reflect this about the line $y = x$ first, it becomes the point $(\frac{1}{2},\frac{\sqrt{3}}{2})$. This is the intersection of the ray at an angle of 60 degree with the $x$-axis and the unit circle.

So, if we rotate next 60 degrees counter-clockwise, we should wind up with the intersection of the ray at an angle of 120 degrees with the $x$-axis, which is:

$(-\frac{1}{2},\frac{\sqrt{3}}{2})$.

Ok, now let's do it the "other way".

First we rotate by 60 degrees, which takes us to the intersection of the unit circle with the y-axis on its upper half (30 + 60 = 90), which gives us the point $(0,1)$.

Next, reflecting (which just changes the $x$ and $y$ coordinates) gives us the point $(1,0)$, which is different than what we got applying the maps in the other order.

In general, in "most" mathematics, when "multiplication" is actually a kind of composition, then:

$A \circ B$ means: FIRST do $B$, THEN do $A$:

$ABv = (A\circ B)v = A(Bv) = A(B(v))$:

$v \to Bv \to ABv$.

Now, let's use matrices, and see if we get the same answers as I got above.

Let $B$ be the reflection (since the problem says to do that first). You have correctly given this matrix as:

$B = \begin{bmatrix}0&1\\1&0 \end{bmatrix}$.

Therefore, we have:

$B(\frac{\sqrt{3}}{2},\frac{1}{2}) = \begin{bmatrix}0&1\\1&0 \end{bmatrix} \begin{bmatrix}\frac{\sqrt{3}}{2}\\ \frac{1}{2} \end{bmatrix} = \begin{bmatrix} \frac{1}{2}\\ \frac{\sqrt{3}}{2} \end{bmatrix}$

So far, so good.

You have also correctly given the rotation as:

$A = \begin{bmatrix}\frac{1}{2}&-\frac{\sqrt{3}}{2}\\ \frac{\sqrt{3}}{2}&\frac{1}{2} \end{bmatrix}$

So:

$AB(\frac{\sqrt{3}}{2},\frac{1}{2}) = A(\frac{1}{2},\frac{\sqrt{3}}{2}) = \begin{bmatrix}\frac{1}{2}&-\frac{\sqrt{3}}{2}\\ \frac{\sqrt{3}}{2}&\frac{1}{2} \end{bmatrix} \begin{bmatrix}\frac{1}{2}\\ \frac{\sqrt{3}}{2} \end{bmatrix} = \begin{bmatrix}-\frac{1}{2}\\ \frac{\sqrt{3}}{2} \end{bmatrix}$

Since this agrees with what I found above, it appears we are on the right track.

Now, the "all-in-one-fell-swoop" matrix for the composition, should be $AB$, which is:

$AB = \begin{bmatrix}\frac{1}{2}&-\frac{\sqrt{3}}{2}\\ \frac{\sqrt{3}}{2}&\frac{1}{2} \end{bmatrix} \begin{bmatrix}0&1\\1&0 \end{bmatrix} = \begin{bmatrix}-\frac{\sqrt{3}}{2}&\frac{1}{2}\\ \frac{1}{2}&\frac{\sqrt{3}}{2} \end{bmatrix}$

Let's verify as a sanity check that this takes our chosen point to the same end result as "doing the steps one at a time":

$AB(\frac{\sqrt{3}}{2},\frac{1}{2}) = \begin{bmatrix}-\frac{\sqrt{3}}{2}&\frac{1}{2}\\ \frac{1}{2}&\frac{\sqrt{3}}{2} \end{bmatrix} \begin{bmatrix}\frac{\sqrt{3}}{2}\\ \frac{1}{2} \end{bmatrix} = \begin{bmatrix}-\frac{1}{2}\\ \frac{\sqrt{3}}{2} \end{bmatrix}$

which is exactly what we got before.

As an aside, note that:

$BA = \begin{bmatrix}0&1\\1&0 \end{bmatrix} \begin{bmatrix}\frac{1}{2}&-\frac{\sqrt{3}}{2}\\ \frac{\sqrt{3}}{2}&\frac{1}{2} \end{bmatrix} = \begin{bmatrix}\frac{\sqrt{3}}{2}&\frac{1}{2}\\ \frac{1}{2}&-\frac{\sqrt{3}}{2} \end{bmatrix}$

which is NOT the same matrix as $AB$, so we should not expect it to have the same effect. Indeed, using our same "test point", we find that:

$BA(\frac{\sqrt{3}}{2},\frac{1}{2}) = \begin{bmatrix}\frac{\sqrt{3}}{2}&\frac{1}{2}\\ \frac{1}{2}&-\frac{\sqrt{3}}{2} \end{bmatrix} \begin{bmatrix}\frac{\sqrt{3}}{2}\\ \frac{1}{2} \end{bmatrix} = \begin{bmatrix}1\\0 \end{bmatrix}$

which again agrees with our "non-matrix" analysis at the beginning of this post.

Again, I want to stress that it is NOT customary to do rotations or reflections first, but rather, if you are instructed to apply $B$, then $A$, the matrix you want is going to be $AB$, not $BA$ as you might think from "reading left-to-right" (in other words, the composition of two functions $f\circ g$ is "order-reversing", we do $g$ first, not $f$).