Tool to calculate matrix products. Matrix product algebra consists of the multiplication of matrices (square or rectangular).
Matrix Product - dCode
Tag(s) : Matrix
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
The matrix product is the name given to the most common matrix multiplication method.
$ M_1=[a_{ij}] $ is a matrix of $ m $ rows and $ n $ columns and $ M_2=[b_{ij}] $ is a matrix of $ n $ rows and $ p $ columns (all formats are possible 2x2, 2x3, 3x2, 3x3, 3x4, 4x3, etc.). The matrix product $ M_1.M_2 = [c_{ij}] $ is a matrix of $ m $ rows and $ p $ columns, with: $$ \forall i, j: c_{ij} = \sum_{k=1}^n a_{ik}b_{kj} $$
The multiplication of 2 matrices $ M_1 $ and $ M_2 $ is noted with a point $ \cdot $ or . so $ M_1 \cdot M_2 $ (the same point as for the dot product)
The matrix product is only defined when the number of columns of $ M_1 $ is equal to the number of rows of $ M_2 $ (matrices are called compatible)
The multiplication of 2 matrices $ M_1 $ and $ M_2 $ forms a result matrix $ M_3 $. The matrix product consists in carrying out additions and multiplications according to the positions of the elements in the matrices $ M_1 $ and $ M_2 $.
$$ M_1 = \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix} \\ M_2 = \begin{bmatrix} b_{11} & b_{12} & \cdots & b_{1p} \\ b_{21} & b_{22} & \cdots & b_{2p} \\ \vdots & \vdots & \ddots & \vdots \\ b_{n1} & b_{n2} & \cdots & b_{np} \end{bmatrix} \\ M_1 \cdot M_2 = \begin{bmatrix} a_{11}b_{11} +\cdots + a_{1n}b_{n1} & a_{11}b_{12} +\cdots + a_{1n}b_{n2} & \cdots & a_{11}b_{1p} +\cdots + a_{1n}b_{np} \\ a_{21}b_{11} +\cdots + a_{2n}b_{n1} & a_{21}b_{12} +\cdots + a_{2n}b_{n2} & \cdots & a_{21}b_{1p} +\cdots + a_{2n}b_{np} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1}b_{11} +\cdots + a_{mn}b_{n1} & a_{m1}b_{12} +\cdots + a_{mn}b_{n2} & \cdots & a_{m1}b_{1p} +\cdots + a_{mn}b_{np} \end{bmatrix} $$
To calculate the value of the element of the matrix $ M_3 $ in position $ i $ and column $ j $, extract the row $ i $ from the matrix $ M_1 $ and the row $ j $ from the matrix $ M_2 $ and calculate their dot product. That is, multiply the first element of row $ i $ of $ M_1 $ by the first element of column $ j $ of $ M_2 $, then the second element of row $ i $ of $ M_1 $ by the second element of the column $ j $ of $ M_2 $, and so on, note the sum of the multiplications obtained, it is the value of the scalar product, therefore of the element in position $ i $ and column $ j $ in $ M_3 $.
Example: $$ \begin{bmatrix} 1 & 0 \\ -2 & 3 \end{bmatrix} \cdot \begin{bmatrix} 2 & -1 \\ 4 & -3 \end{bmatrix} = \begin{bmatrix} 1 \times 2 + 0 \times 4 & 1 \times -1 + 0 \times -3 \\ -2 \times 2 + 4 \times 3 & -2 \times -1 + 3 \times -3 \end{bmatrix} = \begin{bmatrix} 2 & -1 \\ 8 & -7 \end{bmatrix} $$
The matrix product between a matrix $ M $ of dimensions $ m \times n $ and a column vector $ V $ of dimension $ n \times 1 $ results in a new column vector of dimension $ m \times 1 $ .
The principle is similar for a row vector.
The product of the matrix $ M=[a_{ij}] $ by a scalar (number) $ \lambda $ is a matrix of the same size as the initial matrix $ M $, with each item of the matrix multiplied by $ \lambda $.
$$ \lambda M = [ \lambda a_{ij} ] $$
Associativity: $$ A \times (B \times C) = (A \times B) \times C $$
Distributivity: $$ A \times (B + C) = A \times B + A \times C $$
$$ (A + B) \times C = A \times C + B \times C $$
$$ \lambda (A \times B) = (\lambda A) \times B = A \times (\lambda B) $$
The order of the operands matters with matrix multiplication, so $$ M_1.M_2 \neq M_2.M_1 $$ (non-commutativity, except in special cases)
There is a matrix product compatible with any matrix sizes (3x3,4x4,5x5,etc.): the Kronecker product
dCode retains ownership of the "Matrix Product" source code. Any algorithm for the "Matrix Product" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Matrix Product" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Matrix Product" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Matrix Product" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Matrix Product on dCode.fr [online website], retrieved on 2025-04-16,