Math Calculators, Lessons and Formulas

It is time to solve your math problem

mathportal.org
« Matrices Definitions
Linear Algebra - Matrices: (lesson 2 of 3)

Matrix Addition and Multiplication

Addition of Matrices

Denote the sum of two matrices $A$ and $B$ (of the same dimensions) by $C = A + B..$ The sum is defined by adding entries with the same indices

$c_{ij} \equiv a_{ij} + b_{ij}$

over all $i$ and $j$.

Example:

$ \left[ {\begin{array}{*{20}{c}} \color{red}{1}&\color{blue}{2}\\ 3&\color{purple}{4} \end{array}} \right] + \left[ {\begin{array}{*{20}{c}} \color{red}{5}&\color{blue}{6}\\ 7&\color{purple}{8} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {\color{red}{1 + 5}}&{\color{blue}{2 + 6}}\\ {3 + 7}&{\color{purple}{4 + 8}} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} 6&8\\ {10}&{12} \end{array}} \right] $

Subtraction of Matrices

Subtraction is performed in analogous way.

Example:

$ \left[ {\begin{array}{*{20}{c}} \color{red}{1}&\color{blue}{2}\\ 3&\color{purple}{4} \end{array}} \right] - \left[ {\begin{array}{*{20}{c}} \color{red}{5}&\color{blue}{6}\\ 7&\color{purple}{8} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {\color{red}{1 - 5}}&{\color{blue}{2 - 6}}\\ {3 - 7}&{\color{purple}{4 - 8}} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {-4}&{-4}\\ {-4}&{-4} \end{array}} \right] $

Scalar multiplication

To multiply a matrix with a real number, each element is multiplied by that number.

Example:

$ \color{red}{5} \cdot \left[ {\begin{array}{*{20}{l}} 1&2&3\\ { - 1}&{ - 2}&{ - 3} \end{array}} \right] = \left[ {\begin{array}{*{20}{l}} {\color{red}{5} \cdot 1}&{\color{red}{5} \cdot 2}&{\color{red}{5} \cdot 3}\\ {\color{red}{5} \cdot ( - 1)}&{\color{red}{5} \cdot ( - 2)}&{\color{red}{5} \cdot ( - 3)} \end{array}} \right] = \left[ {\begin{array}{*{20}{l}} 5&{10}&{15}\\ { - 5}&{ - 10}&{ - 15} \end{array}} \right] $

Multiplication of a row vector by a column vector

This multiplication is only possible if the row vector and the column vector have the same number of elements. To multiply the row by the column, corresponding elements are multiplied, then added to the results.

Example:

$ \underbrace {\left[ {\begin{array}{*{20}{c}} \color{red}{1}&\color{blue}{2}&3 \end{array}} \right]}_{1 \times \color{blue}{3}} \cdot \underbrace {\left[ {\begin{array}{*{20}{c}} \color{red}{4}\\ \color{blue}{5}\\ 6 \end{array}} \right]}_{\color{blue}{3} \times 1} = \color{red}{1 \cdot 4} + \color{blue}{2 \cdot 5} + 3 \cdot 6 = \underbrace {22}_{1 \times 1} $

If the row vector and the column vector are not of the same length, their product is not defined.

Example:

$ \underbrace {\left[ {\begin{array}{*{20}{c}} 1&2&3&4 \end{array}} \right]}_{1 \times \color{red}{4}} \cdot \underbrace {\left[ {\begin{array}{*{20}{c}} 4\\ 5\\ 6 \end{array}} \right]}_{\color{red}{3} \times 1} = \color{red}{\text{NOT DEFINED}} $

The Product of a Row Vector and Matrix

When the number of elements in row vector is the same as the number of rows in the second matrix then this matrix multiplication can be performed.

Example:

$ \underbrace {\left[ {\begin{array}{*{20}{c}} \color{red}{1}&\color{red}{2}&\color{red}{3} \end{array}} \right]}_{1 \times \color{blue}{3}} \cdot \underbrace {\left[ {\begin{array}{*{20}{c}} \color{blue}{2}&\color{pink}{1}&\color{orange}{3}\\ \color{blue}{3}&\color{pink}{3}&\color{orange}{2}\\ \color{blue}{4}&\color{pink}{1}&\color{orange}{2} \end{array}} \right]}_{\color{blue}{3} \times 3} = \left[ {\begin{array}{*{20}{c}} {\color{red}{1} \cdot \color{blue}{2} + \color{red}{2} \cdot \color{blue}{3} + \color{red}{3} \cdot \color{blue}{4}}\\ {\color{red}{1} \cdot \color{pink}{1} + \color{red}{2} \cdot \color{pink}{3} + \color{red}{3} \cdot \color{pink}{1}}\\ {\color{red}{1} \cdot \color{orange}{3} + \color{red}{2} \cdot \color{orange}{2} + \color{red}{3} \cdot \color{orange}{2}} \end{array}} \right] = \underbrace {\left[ {\begin{array}{*{20}{c}} {20}\\ {10}\\ {13} \end{array}} \right]}_{1 \times 3} $

If the number of elements in row vector is NOT the same as the number of rows in the second matrix then their product is not defined.

Example:

$ \underbrace {\left[ {\begin{array}{*{20}{c}} \color{red}{1}&\color{red}{2}&\color{red}{3} \end{array}} \right]}_{1 \times \color{red}{3}} \cdot \underbrace {\left[ {\begin{array}{*{20}{l}} 1&3&5\\ 2&4&6 \end{array}} \right]}_{\color{red}{2} \times 3} = \color{red}{\text{NOT DEFINED}} $

Matrix Multiplication - General Case

When the number of columns of the first matrix is the same as the number of rows in the second matrix then matrix multiplication can be performed.

Examples

Multiplying a $2 \times 3$ matrix by a $3 \times 2$ matrix is possible, and it gives a $2 \times 2$ matrix as the result.

$ \underbrace {\left[ {\begin{array}{*{20}{l}} ?&?&?\\ ?&?&? \end{array}} \right]}_{2 \times \color{blue}{3}} \cdot \underbrace {\left[ {\begin{array}{*{20}{l}} ?&?\\ ?&?\\ ?&? \end{array}} \right]}_{\color{blue}{3} \times 2} = \underbrace {\left[ {\begin{array}{*{20}{c}} ?&?\\ ?&? \end{array}} \right]}_{2 \times 2} $

Multiplying a $2 \times 3$ matrix by a $2 \times 3$ matrix is not defined.

$ \underbrace {\left[ {\begin{array}{*{20}{l}} ?&?&?\\ ?&?&? \end{array}} \right]}_{2 \times \color{red}{3}} \cdot \underbrace {\left[ {\begin{array}{*{20}{l}} ?&?&?\\ ?&?&? \end{array}} \right]}_{\color{red}{2} \times 3} = \color{red}{\text{NOT DEFINED}} $

Here is an example of matrix multiplication for two concrete matrices

Example: Find the product $AB$ where $A$ and $B$ are matrices:

$ A = \left[ {\begin{array}{*{20}{l}} 1&3&5\\ 2&4&6 \end{array}} \right] \ \ \ \ B = \left[ {\begin{array}{*{20}{l}} 3&6\\ 1&4\\ 5&2 \end{array}} \right] $

Solution:

The product $AB$ is defined since $A$ is a $2 \times 3$ matrix and $B$ is a $3 \times 2$ matrix. The answer is a $2 \times 2$ matrix. The multiplication is divided into 4 steps.

Step 1:

Multiply the 1st row of the first matrix and 1st column of the second matrix, element by element. The result goes in the position (1, 1)

$ \left[ {\begin{array}{*{20}{l}} \color{red}{1}&\color{red}{3}&\color{red}{5}\\ 2&4&6 \end{array}} \right] \cdot \left[ {\begin{array}{*{20}{l}} \color{blue}{3}&6\\ \color{blue}{1}&4\\ \color{blue}{5}&2 \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {\color{red}{1} \cdot \color{blue}{3} + \color{red}{3} \cdot \color{blue}{1} + \color{red}{5} \cdot \color{blue}{5}}&?\\ ?&? \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {31}&?\\ ?&? \end{array}} \right] $

Step 2:

Now, multiply the 1st row of the first matrix and 2nd column of the second matrix. The result goes in the position (1, 2)

$ \left[ {\begin{array}{*{20}{l}} \color{red}{1}&\color{red}{3}&\color{red}{5}\\ 2&4&6 \end{array}} \right] \cdot \left[ {\begin{array}{*{20}{l}} 3&\color{blue}{6}\\ 1&\color{blue}{4}\\ 5&\color{blue}{2} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} 31&{\color{red}{1} \cdot \color{blue}{6} + \color{red}{3} \cdot \color{blue}{4} + \color{red}{5} \cdot \color{blue}{2}}\\ ?&? \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {31}&{28}\\ ?&? \end{array}} \right] $

Step 3:

Next, multiply 2nd row of the first matrix and the 1st column of the second matrix. The result goes in the position (2, 1)

$ \left[ {\begin{array}{*{20}{l}} 1&3&5\\ \color{red}{2}&\color{red}{4}&\color{red}{6} \end{array}} \right] \cdot \left[ {\begin{array}{*{20}{l}} \color{blue}{3}&6\\ \color{blue}{1}&4\\ \color{blue}{5}&2 \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} 31&28\\ {\color{red}{2} \cdot \color{blue}{3} + \color{red}{4} \cdot \color{blue}{1} + \color{red}{6} \cdot \color{blue}{5}}&? \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {31}&{28}\\ {40}&? \end{array}} \right] $

Step 4:

Finally, multiply 2nd row of the first matrix and the 2st column of the second matrix. The result goes in the position (2, 2)

$ \left[ {\begin{array}{*{20}{l}} 1&3&5\\ \color{red}{2}&\color{red}{4}&\color{red}{6} \end{array}} \right] \cdot \left[ {\begin{array}{*{20}{l}} \color{blue}{3}&6\\ \color{blue}{1}&4\\ \color{blue}{5}&2 \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} 31&28\\ 40&{\color{red}{2} \cdot \color{blue}{6} + \color{red}{4} \cdot \color{blue}{4} + \color{red}{6} \cdot \color{blue}{2}} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {31}&{28}\\ {40}&{40} \end{array}} \right] $

So, the result is:

$ \left[ {\begin{array}{*{20}{l}} 1&3&5\\ 2&4&6 \end{array}} \right] \cdot \left[ {\begin{array}{*{20}{l}} 3&6\\ 1&4\\ 5&2 \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {31}&{28}\\ {40}&{40} \end{array}} \right] $

Example 2: Find the product AB where A and B are matrices given by:

$ A = \left[ {\begin{array}{*{20}{c}} 2&1\\ 3&5 \end{array}} \right] \ \ \ \ \ B = \left[ {\begin{array}{*{20}{c}} { - 2}&3\\ 4&{ - 1} \end{array}} \right] $

Solution:

$ A \cdot B = \left[ {\begin{array}{*{20}{c}} 2&1\\ 3&5 \end{array}} \right] \cdot \left[ {\begin{array}{*{20}{c}} { - 2}&3\\ 4&{ - 1} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {2 \cdot ( - 2) + 1 \cdot 4}&{2 \cdot 3 + 1 \cdot ( - 1)}\\ {3 \cdot ( - 2) + 5 \cdot 4}&{3 \cdot 3 + 5 \cdot ( - 1)} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} 0&5\\ {14}&4 \end{array}} \right] $