To rotate a $2\times2$ matrix by $180$ degrees around the center point, I have the following formula:

$PAP$ = Rotated Matrix, where

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

$$A= \begin{bmatrix} a & b\\ c & d \end{bmatrix}$$

And the resulting matrix will equal \begin{bmatrix} d & c\\ b & a \end{bmatrix}

I need to have this in the form of: $AP$ = Rotated matrix.

How would I get it to this form?


There is no such $2 \times 2$ matrix $P$ which will do what you want for a general $A$. This is because you need to rearrange both the rows and columns and so need a matrix action on the left and on the right. To see this explicitly, define $$P = \left[\begin{array}{cc} p_1 & p_2 \\ p_3 & p_4 \end{array} \right] $$

Compute $AP$ and notice there is never an $a$ term which appears on the bottom row.

Edit for the case where $a,b,c,d$ are fixed variables and we can write $P$ in terms of them:

If $A$ is invertible, $$P = A^{-1}B$$ where $B$ is the rotated form of $A$. If you don't care about singular matrices (since most matrices are non-singular), then just use this. Otherwise expand out $AP$ as I mentioned before and find values for $P$ which will make it work, if possible.

  • $\begingroup$ Ok, thanks for the help :/ Is there any chance that I have misunderstood the question in my example sheet? This is what it looks like here: i48.tinypic.com/23h3tl0.jpg $\endgroup$ – Taylor Dale Mar 13 '13 at 0:37
  • $\begingroup$ Ah, it seems as though you are to construct the matrix $T$ where the coefficients $a, b, c, d$ are fixed. In that case you are solving a linear system of $4$ equations with $4$ unknowns and so you can solve for $P$. $\endgroup$ – muzzlator Mar 13 '13 at 0:44
  • $\begingroup$ @Taylor: I wish you'd posted that link in your other question! Sorry that my answer here wasn't enough to help you. $\endgroup$ – Cameron Buie Mar 13 '13 at 0:52

The example sheet asks for a matrix $T$ so that $AT=B$ where $A$ is $[[a,b],[c,d]]$ and $B=[[d,c],[b,a]].$ (writing 2x2 matrices as [[row1],[row2]]. Also the example sheet doesn't say that your matrix $[[0,1],[1,0]]$ needs to be involved in the matrix $T$ you're looking for.

Now note that $AT=B$ becomes $T=A^{-1}B$ when both sides are multiplied on the left by $A^{-1}.$ This makes it clear that for a solution $T$ to exist you need $A$ to be invertible, that is the determinant $ad-bc \ne 0.$ It also makes it clear that, if such a matrix $T$ exists, its entries are uniquely determined, provided $A$ is invertible.

Calculating $T$ by this formula $T=A^{-1}B$ then gives $T=[[p,q],[r,s]]$ where, using $D=ad-bc$ to abbreviate the determinant of $A$, we have $$p=(-b^2+d^2)/D,\ q=(-ab+cd)/D,\\ r=(ab-cd)/D,\ s=(a^2-c^2)/D.$$
Of course it is natural that $T$ has coefficients depending on those of the matrices $A,B$ since they were used to calculate $T$. This makes one wonder why bother computing $T$ at all, since in a program it would be simpler to just rearrange the entries of a given matrix $A$, rather than come up with a matrix $T$ which can only be computed if you already know the "rotated" matrix $B$.


There are matrices $A$ for which no such $P$ exists. For example, if $$A=\left[\begin{array}{cc}0 & 0\\c & d\end{array}\right]$$ for some $c,d$ not both $0$, then for any $$P=\left[\begin{array}{cc}\alpha & \beta\\\gamma & \delta\end{array}\right]$$ we have $$AP=\left[\begin{array}{cc}0 & 0\\c\alpha+d\gamma & c\beta+d\delta\end{array}\right]\neq\left[\begin{array}{cc}d & c\\0 & 0\end{array}\right].$$

Our problem, then, is worse than the impossible task of trying to find a single matrix $P$ that rotates all matrices $A$ in this way--sometimes, we can't even rotate a given matrix like this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.