Dimension of the $n\times n $ matrices with some conditions What is the dimension of the space of $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 but I get $n-1$ I don't know it is right or wrong??
 A: The space of $n\times n$ matrices has dimension $n^2$.
You're adding two independent linear conditions.
Hence the dimension you seek is $n^2-2$.
More precisely, $(a_{ij}) \mapsto (\sum a_{1j}, \sum a_{ii})$ is a surjective linear transformation  $\mathbb R^{n\times n} \to \mathbb R^2$. Hence its kernel has dimension $n^2-2$.
A: A more basic, intuitive answer:
The space of $n\times n$ real matrices has dimension $n^2$, because a basis (in fact, any basis) of this space has $n^2$ vectors. That is to say, we can write any of the matrices in the space as a linear combination of $n^2$ matrices.
As an example, any $2\times2$ matrix can be written as
$$\alpha_1\begin{bmatrix}1&0\\0&0\end{bmatrix} + \alpha_2\begin{bmatrix}0&1\\0&0\end{bmatrix} + \alpha_3\begin{bmatrix}0&0\\1&0\end{bmatrix} +\alpha_4\begin{bmatrix}0&0\\0&1\end{bmatrix}$$
(a linear combination of four matrices) for scalars $\alpha_1, \alpha_2, \alpha_3, \alpha_4 \in \mathbb{R}$.
We can think of each basis vector as being a degree of freedom. The dimension of the space then means: ‘how many choices must we make when constructing a vector?’
With your requirements, we actually only need two ($2^2 - 2$) matrices for our basis in the case of $2 \times 2$ matrices
$$\alpha_1\begin{bmatrix}1&-1\\0&-1\end{bmatrix} + \alpha_2\begin{bmatrix}0&0\\1&0\end{bmatrix}$$
since the sum of the first row and main diagonal entries must be zero.
This result extends to $n \times n$ matrices—our basis will always be two less than $n^2$.
But why can we always remove exactly two of the basis vectors?
Consider constructing the first row of the matrix. For each of the first $n-1$ entries (in whatever order) we can choose whatever values we like, and it doesn’t particularly matter—we have a free choice. But when we get to the last entry, there is only one possible value such that the sum of the row is zero. So we in fact only have $n-1$ choices for the first row. The process is exactly the same for the main diagonal, and so we are making two fewer choices and therefore have two fewer basis vectors.
This is why the dimension of the space you are considering is $n^2 - 2$.
