# dimension of a vector space

Let $A$ be an $n\times n$ diagonal matrix with characteristic polynomial $(x-a)^p(x-b)^q$ where $a$ and $b$ are distinct real numbers. Let $V$ be the real vector space of all $n\times n$ matrices $B$ such that $AB=BA$. Determine the dimension of $V$.

I know for certain that if a matrix $Q$ commutes with a diagonalizable matrix $P$ then $Q$ is also diagonalizable provided $P$ has distinct eigen values.

In here this is not the case.

• It is not true that if Q commutes with a diagonalisable matrix, then, Q is diagonalisable: as you know there are matrices which are not diagonalisable but every matrix commutes with the identity matrix, a diagonal matrix. – knsam Jan 17 '14 at 2:55
• yeah sorry... edited it – tattwamasi amrutam Jan 17 '14 at 2:57
• It is advisable to go for $2\times 2$ and $3\times 3$ to get some idea – user87543 Jan 17 '14 at 2:57
• After reordering the basis if necessary, you can write the matrix as a diagonal $2 \times 2$ block matrix, with scalar matrices on the diagonal. Now look for $2 \times 2$ block matrices that commute with that one. – user121926 Jan 17 '14 at 3:00
• In B, you will have two blocks of orders p and q respectively. So, what is dimension of an $n \times n$ matrix? Hence dim V $= p^2 q^2$. – wannadeleteacct Jan 17 '14 at 10:56

Note that the dimension is not completely determined by $p$ and $q$; if we take $$A=\left(\begin{array}{cc}1&0\\0&1\end{array}\right)$$ then the dimension is 4, but the dimension is only 2 if we take $$A=\left(\begin{array}{cc}1&1\\0&1\end{array}\right).$$
• The problem says $A$ is a diagonal matrix. – Gerry Myerson Oct 9 '14 at 9:06