3
$\begingroup$

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

A*A*A matrix of nxn rows

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

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

2 Answers 2

2
$\begingroup$

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$).

$\endgroup$
3
  • $\begingroup$ 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}]. $\endgroup$ Commented Aug 18, 2014 at 11:27
  • $\begingroup$ @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. $\endgroup$ Commented Aug 18, 2014 at 14:22
  • $\begingroup$ Thank you very much. It is the most accurate and well developed solution to this problem. $\endgroup$
    – ditmark12
    Commented Aug 18, 2014 at 22:51
0
$\begingroup$

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

matrixExamples

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.