Calculating number of non-zero elements in a lower triangular matrix

It is possible to calculate the number of the maximum amount of non-zero elements in a lower (or upper) triangular matrix.

The simplest way to do it is to write a $N\times N$ matrix:

$$ \mathbb{A}=\left[\begin{array}{cccc} a_{1,1}&a_{1,2}&\cdots&a_{1,N}\\ a_{2,1}&a_{2,2}&\cdots&a_{2,N}\\ \vdots&\vdots&\vdots&\vdots\\ a_{N,1}&a_{N,2}&\cdots&a_{N,N}\\ \end{array}\right], $$

and notice that for a lower triangular matrix, the non-zero elements $a_{i,j}$ have $i\geq j$. Thus, the indices of the non-zero elements are identified by the unique ordered pairs, $(i,j)$, with $i\in[1,N]$ and $j\in[1,N]$, such that $i\geq j$.

So you have the pairs:

$$ \overbrace{(1,1)}^{1 pair}\\ \overbrace{(2,1)\ (2,2)}^{2 pairs}\\ \vdots\\ \overbrace{(N,1)\ (N,2)\ \cdots\ (N,N)}^{N pairs}, $$

and the amount of non-zero elements, $E$, is exactly the amount of unique pairs you have. Now you just have to sum:

$$ E=\sum\limits_{n=1}^{N}n=\dfrac{\left(1+N\right)N}{2} $$


My colleague (kudos to him) and I discussed the parallels for counting the elements in a triangular matrix to a combination.

Given that you do not want to include the main diagonal in your count, you can simply express this as a combination, as you want to find all possible combinations of 2 elements (bar the combination of an element with itself):

$${n \choose k}=\frac{n!}{k!(n-k)!}$$

So for the case of $k=2$, this will be:

$$\frac{n!}{2!(n-2)!}$$

...which nicely reduces down to:

$$\frac{n!}{2!(n-2)!}$$ $$=\frac{1}{2!}\cdot\frac{n!}{(n-2)!}$$ $$=\frac{1}{2}\cdot n(n-1)$$ $$=\frac{n(n-1)}{2}$$

For the reduction from $\frac{n!}{(n-2)!}$ to $n(n-1)$, think of:

$$\require{cancel} \frac{4!}{(4-2)!} = \frac{4\cdot3\cdot \cancel{2\cdot1}}{\cancel{2\cdot1}}=12$$

...which leaves you essentially with $n(n-1)$.

This is similar to result of Girardi's answer, with the exception of leaving out all elements of the main diagonal.


In case your matrix is lower triangular It is a square matrix.

I agree with @copper.hat 37 comment. The number of non-zero entries isn't determenistic. As long as all the entries above the main diagonal are zeros you can put a zero wherever you want and therefore It can be changed.

For example for two 3x3 lower triangular matrices : \begin{bmatrix} 1 & 0 & 0 \\ 1 & 1 & 0 \\ 1 & 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 1 & 1 & 1 \end{bmatrix}

you have different number of non-zeors entries.

It is possible though, to calculate the minimum number of zeros of a lower triangular matrix. In order to do so you just have to understand how's the number of elements above the main diagonal grows, these must be zeros.

For example 3x3, 4x4, 5x5:

\begin{bmatrix} 1 & 0 & 0 \\ 1 & 1 & 0 \\ 1 & 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 1 & 1 & 0 & 0 \\ 1 & 1 & 1 & 0\\ 1 & 1 & 1 & 1 \end{bmatrix}

\begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 1 & 1 & 0 & 0 & 0\\ 1 & 1 & 1 & 0 & 0\\ 1 & 1 & 1 & 1 & 0 \\ 1 & 1 & 1 & 1 & 1 \end{bmatrix}

If you count how much zeros (minimum case) you have, you'll get 3,6,10 respectively to the matrices above.

If this is the case a fourmla can be extracted.

Hope It helps =]