# How many $2 \times 2$ matrices are there with entries from the set ${\{0,1,2,…,i}\}$ in which there are no zeros rows and no zero columns?

How many $2 \times 2$ matrices are there with entries from the set ${\{0,1,2,...,i}\}$ in which there are no zeros rows and no zero columns?

attempt: Suppose we have a matrix $\begin{pmatrix} a & b \\ c & d \end{pmatrix}$. Then we don't want $\begin{pmatrix} 0 & 0 \\ 0 & 0 \end{pmatrix}$ or $\begin{pmatrix} 0 & 0 \\ c & d \end{pmatrix}$ or $\begin{pmatrix} a & b \\ 0 & 0 \end{pmatrix}$.

Similarly for the columns. Then we have the first case: that all of the $a,b,c,d \neq 0$,and so we have $i^4$ options to choose such a matrix.

second case: we have that $\begin{pmatrix} 0 & b \\ c & 0 \end{pmatrix}$ or $\begin{pmatrix} a & 0 \\ 0 & d \end{pmatrix}$. so we have $i^2$ or $i^2$ on both,so $2i^2$ ways to choose a matrix.

third case : either the $a,b,c,d$ is zero and the rest nonzero.

• Approaching directly like this would be fine. Breaking into cases based on how many zeroes there are, there are $4$ choices for the location of a single zero, $1$ choice for the location of no zeroes, and $2$ choices for the location of two zeroes. You can calculate the number of poossiblities for each choice in each case separately easily enough and add. – JMoravitz Mar 13 '17 at 0:43
• You're missing the situations where you have only one zero. There are four of those so $4i^3$. – Sentinel135 Mar 13 '17 at 0:45
• So then the answer would be $i^4 + 4i^3 + 2i^2$? for such a matrix? – Mahidevran Mar 13 '17 at 0:46
• yes or $i^2(i+2)^2$ – Sentinel135 Mar 13 '17 at 0:49
• @Sentinel135$\ \ i^2(i+2)^2\ne i^4+4i^3+2i^2$ – bof Mar 13 '17 at 0:58

You may count the number of two tuples that can be formed from the elements of your set. clearly there are $(i+1)^2$ two tuples. Now the first entry should not be the vector $(0,0)$ so you have $(i+1)^2-1$ options for first row of marix. You have number of options for second row but then you have to subtract matrices of form $$\begin{pmatrix} 0 & b \\ 0& d \end{pmatrix}$$ and $$\begin{pmatrix} a& 0\\ c & 0 \end{pmatrix}$$ (where $a$, $b$, $c$ and $d$ are non zero) which are $2i^2$ in number.

so your answer should be $${[(i+1)^2-1]}^2-2i^2$$

This is not the smartest solution, but I want to post it as an application of inclusive-exclusive principle (I personally love this principle).

The list/steps below may look lengthy, but it's actually very fast if you think within your head.

Plus, it is very mechanical - just follow the steps, and thus less error-prone.

We have $i+1$ integers to pick for each position.

Start point

Number of all matrix: ${(i+1)^4}$

Subtract

Number of matrix that has $0$ as its first row: ${(i+1)^2}$

Number of matrix that has $0$ as its second row: ${(i+1)^2}$

Number of matrix that has $0$ as is first column: ${(i+1)^2}$

Number of matrix that has $0$ as its second column: ${(i+1)^2}$

Plus

Number of matrix that has $0$ as its first and second row: $1$

Number of matrix that has $0$ as its first row and first column: $(i+1)$

Number of matrix that has $0$ as its first row and second column: $(i+1)$

Number of matrix that has $0$ as its second row and first column: $(i+1)$

Number of matrix that has $0$ as its second row and second column: $(i+1)$

Number of matrix that has $0$ as its first column and second column: $1$

Subtract

Number of matrix that has $0$ as its first row and second row and first column: $1$

Number of matrix that has $0$ as its first row and second row and second column: $1$

Number of matrix that has $0$ as its first row and first column and second column: $1$

Number of matrix that has $0$ as its second row and first column and second column: $1$

Plus

Number of matrix that has $0$ as its all columns and rows: $1$

Thus

The final result $=(i+1)^4-4(i+1)^2+(2+4(i+1))-4+1$ $$=i^2((i+2)^2-2)$$