# Finding the dimension of a given vector space

What is the dimension of the space of all $n \times n$ matrices with real entries which are such that the sum of the entries in the first row and the sum of the diagonal entries are both zero?

I tried by finding number of independent entries. The number of independent entries on the diagonal is $n-1$. The number of upper triangular independent entries is $\frac{n(n-1)}{2}-1(n-1)$, and the number of lowertriangular independent entries is $\frac{n(n-1)}{2}$. Now adding them will give dimension. Am I right?

-
You have $n^2$ entries, and if I understood you correctly you have $2$ (independent) linear equations on these variables that have to be satisfied. This can be compared to solving systems $Ax = b$, where $x$ has dimension $n^2$ and $A$ has rank $2$. – TMM May 8 '12 at 17:33
I didnt get the point of having two independent linear equations? – srijan May 8 '12 at 17:36
In this case, the two equations are $a_{1,1} + a_{1,2} + \ldots + a_{1,n} = 0$ and $a_{1,1} + a_{2,2} + \ldots + a_{n,n} = 0$, where $a_{i,j}$ are the entries of the matrix. – TMM May 8 '12 at 17:37
For the purpose of evaluating dimension, you can imagine the matrix as being written out in "flat" form, the entries of first row, followed by the entries of the second row, and so on, all on the same line. With respect to addition of matrices, the algebra is the same. – André Nicolas May 8 '12 at 17:39
Roughly speaking (this can be made more rigorous), each constraint reduces the ambient dimension by one. Here you have two constraints, and the ambient dimension is $n^2$. hence the answer is $n^2-2$. – copper.hat May 8 '12 at 17:52

All entries except the lower and upper right can be chosen freely, and no matter what you chose them to be, there exists exactly one value for each of those two spots which gives you a matrix on the form you want. This gives $n^2 - 2$.
Roughly speaking, when you have a vector space over $\mathbb R$, $\mathbb C$, or other fields, each equation relating the coordinates will lower the total dimension by one. In this case you have two equations relating coordinates in a vector space of dimension $n^2$ (forgetting for a moment that it is a matrix, and just look at it as an $n^2$-dimensional vector).
Assuming $n\geq2$, you have $n^2$ variables (the entries) and 2 linear equations, which are independent. Hence you have $n^2-2$ free variables. Your space is the space of solutions to those equations, so the dimension of this space will be $n^2-2$