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 $ lines and $ n $ columns and $ M_2=[b_{ij}] $ is a matrix of $ n $ lines 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 $ lines 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 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 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 $$

There is a matrix product compatible with any matrix sizes: the Kronecker product.

dCode retains ownership of the "Matrix Product" source code. Except explicit open source licence (indicated Creative Commons / free), the "Matrix Product" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the "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.) and all data download, script, or API access for "Matrix Product" are not public, same for offline use on PC, tablet, iPhone or Android !

The copy-paste of the page "Matrix Product" or any of its results, is allowed as long as you cite the online source

Reminder : dCode is free to use.

product,multiplication,matrix,scalar,number,2x2,2x3,3x2,3x3,3x4,4x3,4x4,5x5

Source : https://www.dcode.fr/matrix-multiplication

© 2022 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback