Matrix Multiplication

Author

Eric W. Weisstein
April 21, 2002

This notebook downloaded from http://mathworld.wolfram.com/notebooks/LinearAlgebra/MatrixMultiplication.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/MatrixMultiplication.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Two Matrices

With[{m=3,n=2,p=4},
Array[a,{n,m}]Array[b,{m,p}]==Dot[Array[a,{n,m}],Array[b,{m,p}]]
]/.(#[i_,j_]:>Subscript[#,FromDigits[{i,j}]]&/@{a,b})//MatrixForm//TraditionalForm

Three Matrices

MatrixMultiply[d_,n_:10]:=Module[
{m=Table[Random[Integer,{1,n}],{3},{d},{d}],
i,j,k,l},
{Dot@@m,
Table[Sum[m[[1,i,k]]m[[2,k,l]]m[[3,l,j]],{k,2},{l,2}],{i,2},{j,2}]
}
]

MatrixForm/@MatrixMultiply[2]

MatrixForm/@MatrixMultiply[2]