# How to calculate the degrees of freedom of an $r$-ranked matrix with the size being $n\times n$?

Treat matrices as vectors lying in $\mathbb{R}^{n^2}$. It can be imagined matrices with rank $r (r<n)$ are supposed to lie within a manifold of lower dimension. For example, the singular matrices lie within a $(n^2−1)$-dimensional manifold, because they satisfy $\det(M)=0$, the sole constraint. Typically, the number of independent constraints is equal to the difference between those two dimensions.

Alternatively, we call the dimension of that lower-dimensional manifold as "degrees of freedom".

Now how do we calculate the degrees of freedom of an $r$-ranked matrix with size $n\times n$?

The answer says the degrees of freedom is $n^2-(n-r)^2=(2n-r)r$. I try to interpret it as follows: First, by elementary matrices, every matrix $M$ with the rank of $r$ can be transformed into $$M\sim\begin{pmatrix} I_r&0\\ 0&0 \end{pmatrix}_{n\times n}$$

Now the constraints come from the block at bottom right, where the entries are suppressed to be zero. So there are $(n-r)^2$ constraints, which lead to the answer (why the number of constraints do not agree with the number of zeroes is because they are not all independent, intuitively).

The explanation is not formal at all. Can anyone provide a refined version? Thank you~

EDIT: Provide further explanation of "degrees of freedom"

-
Please make the body of the message self-contained; the title is like the writing on the spine of a book: you don't ask readers to read the spine so that the first page is understandable. – Arturo Magidin Jun 13 '11 at 18:41
I don't understand your question, or the answer, or your explanation. What is a "degree of freedom" of a matrix? I know what "degree of freedom" means for the homogeneous linear system represented by the matrix, but in that case the answer would be $n-r$. So I don't know what you mean. – Arturo Magidin Jun 13 '11 at 18:42
@Arturo Magidin, sorry for the ambiguity. Here I treat matrices as vectors lying in $\mathbb{R}^{n^2}$. And matrices with rank $r (r<n)$ are supposed to lie within a manifold of lower dimension. For example, the singular matrices lie within a $(n^2-1)$-dimensional manifold, because they satisfy $\det(M)=0$, the sole constraint. Alternatively, we can call the dimension of that lower-dimensional manifold as "Degree of freedom". – ziyuang Jun 13 '11 at 19:14

## 1 Answer

Generically, the following procedure can be used to construct an $n\times n$ matrix with rank $r$:

1. Choose the first $r$ columns of the matrix, with $n$ degrees of freedom for each column. Generically, the results will be linearly independent.

2. We can now choose the remaining columns to be linear combinations of the first $r$ columns. This gives $r$ degrees of freedom for each column, namely the $r$ coefficients of the linear combinations.

Thus, the dimension of the space of rank-$r$ matrices is $$rn + (n-r)r\text{,}$$ which is the same as $n^2 - (n-r)^2$.

-
 Of course, it doesn't have to be the first $r$ columns that are linearly independent, but the union of a finite number of sets, each with $d$ degrees of freedom, still has $d$ degrees of freedom. – Robert Israel Jun 13 '11 at 19:42 @Robert: Right, the first $r$ columns aren't necessarily linearly independent, but this is generically true, meaning true on a dense open subset of the rank-$r$ matrices. When computing the dimension of a space, it always works to count the degrees of freedom for a generic point. – Jim Belk Jun 13 '11 at 20:01
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}