# Multiplying matrices

Keywords: Multiplying matrices

## Multiplying matrices by scalars

In scalar multiplication, each entry in the matrix is multiplied by the given scalar.

$C=kA\phantom{\rule{0ex}{0ex}}C\left[i,j\right]=c\cdot A\left[i,j\right]$

Example

$C=kA={3}·\left[\begin{array}{ccc}{1}& -2& 3\\ 0& -1& 4\end{array}\right]=\phantom{\rule{0ex}{0ex}}=\left[\begin{array}{ccc}{3}·{1}& 3·\left(-2\right)& 3·3\\ 3·0& 3·-1& 3·4\end{array}\right]=\phantom{\rule{0ex}{0ex}}=\left[\begin{array}{ccc}{3}& -6& 9\\ 0& -3& 12\end{array}\right]\phantom{\rule{0ex}{0ex}}$

## Multiplying matricesl

The component in the ii -th row and the j -th column of C is the dot product between the i -th row of A and the j -th column of B.

In the i -th row of A, the first element is multiplied by the first element of the j -th column of B, then the second element of the i -th row is multiplied by the second element in the j -th column, and thus by the n -th element. Then we add up these products.

B

Example

$\left[\begin{array}{ccc}{1}& {0}& {2}\\ -1& 3& 1\end{array}\right]·\left[\begin{array}{cc}{3}& 1\\ {2}& 1\\ {1}& 0\end{array}\right]=\phantom{\rule{0ex}{0ex}}\left[\begin{array}{cc}\left({1}·{3}+{0}·{2}+{2}·{1}\right)& \left(1·1+0·1+2·0\right)\\ \left(-1·3+0·2+2·1\right)& \left(-1·1+3·1+1·0\right)\end{array}\right]=\phantom{\rule{0ex}{0ex}}\left[\begin{array}{cc}{5}& 1\\ 4& 2\end{array}\right]$

## Some simple rules for multiplying matrices

• The number of columns in the first matrix must be equal to the number of rows in the second matrix.
• The result matrix has the same number of rows as the first matrix and the same number of columns as the second matrix:

${A}_{{m},{n}}·{B}_{{n},{k}}={C}_{{m},{k}}$