2
$\begingroup$

Is there a formula for the product of 3 matrices? That is, if $A \in \mathbb{R}^{m \times n}, B \in \mathbb{R}^{n \times n},$ and $C \in \mathbb{R}^{n \times p}$, and I want the $(i, j)$ entry of the product $D = ABC$, how can I write $D_{i,j}$? I know $(AB)_{i,j} = \sum_{k=1}^na_{ik}b_{kj}$, but I'm not sure if this can be generalized to more than 2 matrices. Thanks for any help.

$\endgroup$

2 Answers 2

2
$\begingroup$

You can done it for a arbritary number of matrices, the case of tree matrices goes $$(AB)_{i,j} = \sum_{k} A_{i,k} B_{k,j} $$ With some renaming we reach $$ (XY)_{a,b} = \sum_{c} X_{a,c} Y_{c,b} $$ So we replace $X$ with $AB$ $$ ((AB)Y)_{a,b} = \sum_{c} (AB)_{a,c} Y_{c,b} $$ $$ ((AB)Y)_{a,b} = \sum_{c} (\sum_{k} A_{a,k} B_{k,c}) Y_{c,b} $$ After some basic manipulations we get $$ (ABY)_{a,b} = \sum_{c} \sum_{k} A_{a,k} B_{k,c} Y_{c,b} $$ Finally replace $Y$ with $C$ $$ (ABC)_{a,b} = \sum_{c} \sum_{k} A_{a,k} B_{k,c} C_{c,b} $$ So we had derivted our triple matrix formula. (And like this we can generalize for n matrices)

$\endgroup$
1
  • 1
    $\begingroup$ Thanks for showing the work! $\endgroup$
    – Jake
    Oct 29, 2021 at 17:06
2
$\begingroup$

It would be similar to the 2 matrices case but it involves 2 nested sums. I am not sure if this is very efficient in practice: $$d_{ij} = \sum_u\sum_va_{iu}b_{uv}c_{vj}$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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