# Making a conjecture concerning a certain upper-triangular matrix

I have searched for commands which will let me to create matrices and do matrix operations, but I don't know how to apply Mathematica to the following exercise.

Make a conjecture for the result of A*A*A, where A is an n x n matrix of the form

I would like to know if Mathematica can calculate A*A*A and the approach I could use to carry out the calculation.

• A.A.A gives the desired product. See the command Dot Commented Aug 18, 2014 at 2:06
• Is this a school homework exercise? We accept such questions, but ask that they be tagged as such. Commented Aug 18, 2014 at 5:35

Bill s already gave an answer as a comment. An explicit proof of the conjecture can be obtained by noting that $$(A^3)_{il}=A_{ij}A_{jk}A_{kl}=\sum_{j=1}^N\sum_{k=1}^N\text{Boole}[i\leq j]\text{Boole}[j\leq k]\text{Boole}[k\leq l]\\ =\sum_{j=1}^N\text{Boole}[i\leq j]\sum_{k=1}^N\text{Boole}[j\leq k]\text{Boole}[k\leq l]\\ =\sum_{j=1}^N\text{Boole}[i\leq j]\sum_{k=1}^N\text{Boole}[j\leq k\wedge k\leq l\ ]\\ =\sum_{j=1}^N\text{Boole}[i\leq j]\left(\text{Boole}[j\leq l](l-j+1)\right)\\ =\sum_{j=1}^N\text{Boole}[i\leq j\wedge j\leq l](l-j+1)\\ =\text{Boole}[i\leq l]\left[\left(\sum_{j=i}^l(l+1)\right)-\left(\sum_{j=i}^lj\right)\right]\\ =\text{Boole}[i\leq l]\left((l+1) (-i+l+1)+\frac{1}{2} (i-l-1) (i+l)\right)\\ =\frac{1}{2}\text{Boole}[i\leq l] (i-l-2) (i-l-1)$$ where Einstein notation was used in the first step.

In Mathematica, the conjecture can be obtained by noting the following:

a = Table[Boole[a <= b], {a, 15}, {b, 15}];
a.a.a // MatrixForm


$$\left( \begin{array}{ccccccccccccccc} 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 & 45 & 55 & 66 & 78 & 91 & 105 & 120 \\ 0 & 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 & 45 & 55 & 66 & 78 & 91 & 105 \\ 0 & 0 & 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 & 45 & 55 & 66 & 78 & 91 \\ 0 & 0 & 0 & 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 & 45 & 55 & 66 & 78 \\ 0 & 0 & 0 & 0 & 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 & 45 & 55 & 66 \\ 0 & 0 & 0 & 0 & 0 & 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 & 45 & 55 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 & 45 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 3 & 6 & 10 & 15 & 21 & 28 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 3 & 6 & 10 & 15 & 21 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 3 & 6 & 10 & 15 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 3 & 6 & 10 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 3 & 6 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 3 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \right)$$

which is the same as the formula I stated previously (for the case $N=15$).

• You can let Mathematica do the work with Simplify[Sum[ Sum[Boole[i <= p] Boole[p <= q] Boole[q <= j], {p, 1, n}], {q, 1, n}], Assumptions -> {(i | j | n) \[Element] Integers, i <= j, i <= n, j <= n}]. Commented Aug 18, 2014 at 11:27
• @b.gatessucks: Yeah, I just wanted to show him how to solve the recurrence by hand, rather than by using Mathematica, since it sounded like his question was from a math course. Commented Aug 18, 2014 at 14:22
• Thank you very much. It is the most accurate and well developed solution to this problem. Commented Aug 18, 2014 at 22:51

code examples for n x n triangularMatrix

Clear@"*"
upperTriangularMatrix[n_][f_] :=
SparseArray[{i_, j_} /; i <= j -> f[i, j], {n, n}]
lowerTriangularMatrix[n_][f_] :=
SparseArray[{i_, j_} /; i >= j -> f[i, j], {n, n}]

(* examples *)
upperTriangularMatrix[10][1 &] // MatrixForm
lowerTriangularMatrix[10][1 &] // MatrixForm
lowerTriangularMatrix[10][#1*#2 &] // MatrixForm

a = upperTriangularMatrix[10][1 &]
a . a . a // MatrixForm
`