# Writing a composite transformation as a matrix multiplication

I am confused about a question on matrix multiplication of a transformation. I have two matrices, P and Q as follows:

$$P = \begin{pmatrix}\frac{1}{2} & \frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & -\frac{1}{2} \end{pmatrix}$$ $$Q = \begin{pmatrix}-\frac{1}{2} & \frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & \frac{1}{2} \end{pmatrix}$$

I am going through a question where I have to find the single transformation equivalent to transformation P followed by transformation Q. Now I know that the notation for transformations on a point p is go from right to left. Eg PQ(p) would mean apply transformation Q then apply transformation P. Is that correct?

Now the answer I need to get to is the result of multiplication matrices QP. So when you do matrix multiplication you always perform as opposite of transformation? Eg transformation PQ(p) above would be written in matrix multiplication form as QP?

It is a little confusing.

Matrices work like functions. If you have functions $f: A \to B$ and $g: B \to C$, and a element $x \in A$, we do first $f(x)$, then $g(f(x)) = (g \circ f)(x)$. Notice that the order is different, we applied $f$, then $g$, but the result ended up being $g \circ f$. It is the same for matrices.
Extra info. for you: The matrix of rotation by a angle $\theta$ is given by $$\begin{pmatrix} \cos \theta & - \sin \theta \\ \sin \theta & \cos \theta\end{pmatrix}$$ This way, $P$ is rotation by $60 \deg$ and $Q$ is rotation by $120 \deg$.
Here's the deal: operating on a point p by a transformation $T$ is written $T(p)$. That is, the point operated on goes to the right of the function being applied. If you wanted to then take the result, $$q = T(p)$$ and apply a transformation $S$, you'd write $S(q)$. Substituting, you'd find that this was $$S(T(p)).$$
Many important transformations can be written in the form of multiplication by a matrix, and one might conjecture that the definition of matrix multiplication was made so that $$T(p) = Mp,$$ where $M$ is a matrix, would work out nicely. Given that, if $T(p) = Mp$ and $S(q) = Kq$, you get that $$S(T(p)) = K(Mp) = (KM)p.$$ So yes, either in applying transformations OR in multiplying matrices for transformations (at least when points are represented by column vectors), you write the matrix for the first operation to the left of the point; the matrix for th next operation to the left of that, and so on.