Search for a tool
Matrix Product

Tool to calculate matrix products. Matrix product algebra consists of the multiplication of matrices (square or rectangular).

Results

Matrix Product -

Tag(s) : Matrix

Share
dCode and more

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!

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Feedback and suggestions are welcome so that dCode offers the best 'Matrix Product' tool for free! Thank you!

Matrix Product

Alphabet

What is a matrix product? (Definition)

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)

How to multiply 2 matrices? (Matrix product)

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}$$

How to multiply a matrix by a scalar?

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} ]$$

What are matrix multiplication properties?

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

How to multiply two matrices of incompatible shapes?

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

Source code

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, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

Cite dCode

The copy-paste of the page "Matrix Product" or any of its results, is allowed as long as you cite dCode!
Cite as source (bibliography):
Matrix Product on dCode.fr [online website], retrieved on 2023-02-08, https://www.dcode.fr/matrix-multiplication

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!