# If product of two matrices is a diagonal matrix and one of them is diagonal matrix , then will other necessarily be a diagonal matrix?

I was asked to find the inverse of matrix $$A=\text{diag}(a_1,a_2,...,a_n)$$

Let $$B$$ be the inverse of $$A$$, then we have to find $$B$$ such that $$AB=I$$ where $$I$$ is identity matrix of same order as of $$A$$.

I began by assuming that $$B$$ is diagonal matrix and by using the fact that the product of two diagonal matrices is itself a diagonal matrix with it's diagonal entries as product of corresponding diagonal entries of given matrices I found $$B$$ as

$$B=\text{diag}(a_1^{-1},a_2^{-1},...,a_n^{-1})$$

Here I assumed that $$B$$ will be a diagonal matrix. Can we prove that if product $$AB=C$$ is a diagonal matrix and $$A$$ is a diagonal matrix, then $$B$$ will necessary be a diagonal matrix?

If we pre multiply by inverse of $$A$$ , then we get $$B=CA^{-1}$$ and I can use the fact I mentioned above but for that I must also that $$A^{-1}$$ will be a diagonal matrix when $$A$$ is a diagonal matrix.

I searched the site and also found following answer If I have a diagonal matrix, is it necessarily the product of two other diagonal matrices?

• You have found a matrix $B$ such that $AB=BA=I$. So you are done, $B$ is the inverse of $A$. (It does not matter how you found that matrix, by inspiration or a miracle or whatever) Oct 21, 2021 at 7:48
• @MartinR That's true I don't doubt my proof but I wanted to tell source of my question and that's why wrote it Oct 21, 2021 at 7:50
• Martin R wants to point out that the inverse is unique. Hence no matter which conditions you imposed on the matrix $B$, as soon as you found one which behaves like the inverse matix, it is the inverse. Oct 21, 2021 at 7:55
• @MartinR Ok so basically what I can do is that use the fact a matrix has unique inverse and show my verification which proofs that inverse of a diagonal matrix is itself a diagonal matrix Oct 21, 2021 at 7:56
• @LalitTolani: Yes, exactly. Note that the counterexamples given in the answers below are all non-invertible matrices. Oct 21, 2021 at 7:58

The answer to the question in the title is "no".

As a counter example, consider $$0 \cdot A = 0$$, where $$0$$ is the zero matrix (which is a diagonal matrix), and $$A$$ can be any (not necessarily diagonal) matrix.

However, if additionally the diagonal matrix in the product is invertible, the answer is "yes", see below.

Consider $$A \cdot D_1 = D_2$$ with diagonal matrices $$D_1$$ and $$D_2$$ such that $$D_1$$ is invertible. Then $$A = D_2 \cdot D_1^{-1}$$, and therefore $$A$$ is diagonal since the inverse of a diagonal matrix as well as the product of two diagonal matrices is again a diagonal matrix.

The other variant $$D_1\cdot A = D_2$$ is done analogously.

• Ok that's a trick counter example :-), what if I say that both are to be non-null matrices only Oct 21, 2021 at 7:48
• @LalitTolani non-null doesn't help. It's not hard to come up with similar counter examples. What makes a difference is invertibility of the involved matrices, see my addition. Oct 21, 2021 at 7:49
• Why $D_2$ needs to be invertible? I mean if it is not invertible , then also A can be diagonal matrix, provide that it must be diagonal matrix Oct 21, 2021 at 8:04
• @LalitTolani Since that is what you wrote :) "If product of two matrices is a diagonal matrix and one of them is diagonal matrix..." For completeness you should also consider the product the other way round, which is $D_1 \cdot A = D_2$ (which works in an analogous way). Oct 21, 2021 at 8:17
• @LalitTolani ah ok. You are right of course, that can be relaxed. I'll update my answer. Oct 21, 2021 at 8:24

Take $$A=\left[\begin{array}{llll}1 & 0 \\ 0 & 0 \end{array}\right],$$

$$B=\left[\begin{array}{llll}1 & 0 \\ 1 & 0 \end{array}\right].$$ Then $$AB=A$$.