# Dimension of diagonal matrices

What is the dimension of the vector space of all diagonal $n \times n$ matrices?

I tried to count how many distinct entries it has.

• What was the result of your counting? Can you answer this when $n=1$, when $n=2$, or when $n=3$? – Jonas Meyer Nov 30 '13 at 10:34
• How many free variables do you have when you impose the matrix to be diagonal? – Beni Bogosel Nov 30 '13 at 10:38
• It is a general question. I want to know how many distinct entries an n x n diagonal matrix usually has in order to compute its dimension. – user112430 Nov 30 '13 at 11:09
• They did not give me any matrix. In general, what is the dimension of the vector space of all n x n diagonal matrices? and Thank you. – user112430 Nov 30 '13 at 11:13
• How many diagonal entries does an $\;n\times n\;$ matrix have? How many degrees of freedom do you have to fill up one such diagonal? So there's your dimension... – DonAntonio Nov 30 '13 at 13:11

Consider the set $\beta = \{D_1, \dotsc, D_n\}$ where $D_i$ is a matrix of all zero entries except $1$ in the $i^\text{th}$ entry along the diagonal. Then this is a basis of the vector space $V$ of all diagonal $n \times n$ matrices. To prove this we need to show $\operatorname{span}(\beta) = V$ and $\beta$ is linearly independent. The first is clearly true since $\operatorname{diag}(a_1, \dotsc, a_n) = a_1D_1 + \dotsb + a_nD_n$. Showing the second criteria is also easy. Suppose $$c_1D_1 + \dotsb + c_nD_n = O$$ for some scalars $c_1, \dotsc, c_n$. Then this gives $\operatorname{diag}(c_1, \dotsc, c_n) = O$ and by definition of equality of two matrices, we must have $c_1 = \dotsb = c_n = 0$. So $\beta$ is a basis. Since it has $n$ elements, $\dim(V) = n$.