# Given a matrix A, how to find B such that AB=BA [duplicate]

This question already has an answer here:

Let $A = \begin{pmatrix} 1 & 1& 1\\ 1 & 2 &3 \\ 1 &4 & 5 \end{pmatrix}$ and $D = \begin{pmatrix} 2 & 0& 0\\ 0 & 3 &0 \\ 0 &0 & 5 \end{pmatrix}$.

It is found that right-multiplication by D multiplies each column of A by the corresponding diagonal entry of D, whereas left-multiplication by D multiplies each row of A by the corresponding diagonal entry of D.

Construct a 3 x 3 matrix B, not the identity matrix or zero matrix, such that $AB=BA$.

## marked as duplicate by user1551 linear-algebra StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Dec 30 '15 at 8:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• What's wrong with $2I$? – Alex Becker Jul 18 '12 at 5:50
• $B = A$ or $B = A^2$, etc., will also work. More generally you want to find $B$ which is simultaneously diagonalizable with $A$. – Cocopuffs Jul 18 '12 at 5:54
• Hehe, thanks. I was rather trying to construct B using the hint in the middle paragraph and had missed the obvious answers. – Ryan Jul 18 '12 at 5:54
• possible duplicates: math.stackexchange.com/questions/92480, math.stackexchange.com/questions/170241 – sdcvvc Jul 18 '12 at 6:10
• The diagonal hint may be misleading, any diagonal matrix satisfying the requirements is necessarily a multiple of the identity matrix. – Ragib Zaman Jul 18 '12 at 6:11

## 3 Answers

Note that the determinant of $A$ is $-2$, so your matrix is invertible i.e. there exists some matrix $B=A^{-1}$ such that $AB=BA=I$. If I calculated this correctly $$B = \begin{pmatrix} 1 & 1/2& -1/2\\ 1 & -2 &1 \\ -1 & 3/2 & -1/2 \end{pmatrix}.$$

As Alex Becker said, we could use any scalar multiple of $I$ or $A^n$ where $A^n = A\cdot A \dots A$ where $A$ is multiplied by itself $A$ times. We could also use $A^{-1}$ or $(A^{-1})^n$.

Suppose we have any matrices $B$ and $C$ that satisfy $AB=BA$ and $AC=CA$. Then, $A(c_1 B + c_2 C) = c_1 A B + c_2 A C = c_1 BA + c_2 CA = (c_1 B + c_2 C)A$.

From this we conclude that the collection of all matrices that commute with $A$ (under matrix multiplication) forms a vector space, since any linear combinations of matrices that commute with $A$ will also commute with $A$.

• Does anyone know what is the basis for this vector space? – A.S Jul 18 '12 at 6:05
• Finding a basis can get quite complicated. If $A$ is diagonalizable it is quite easy, but if $A$ is in Jordan normal form with Jordan blocks of size greater than $1$, determining the matrices which commute with $A$ can get quite tricky, even if $A$ has only the eigenvalue $1$ or $0$. – Geoff Robinson Jul 18 '12 at 8:21

Notice that $A$ is diagonalizable, so any matirx with the same eigenvectors will commute with $A$, for example

$$B = \begin{pmatrix} 0.2481 & 0.31385 & -0.034765 \\ 0.48816 & -0.65821 & 0.76725 \\ -0.20907 & 1.0811 & 0.28335 \end{pmatrix}$$