Skip to main content
Library homepage
 
Engineering LibreTexts

12.1: Basic Matrix Multiplication

  • Page ID
    85044
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    By Carey Smith

    Matrix Multiplication Summary:

    A matrix times a vector (3x3 case):

    \( A*B =
    \begin{matrix}
    |a & b & c| \\
    |p & q & r| \\
    |u & v & w|
    \end{matrix} * \begin{matrix}
    |x| \\
    |y| \\
    |z|
    \end{matrix} = \begin{matrix}
    |a*x & b*y & c*z| \\
    |p*x & q*y & r*z| \\
    |u*x & v*y & w*z|
    \end{matrix}
    \)

    Matrices do not need to be square, but the number of columns in A needs to equal the number of rows in B.

    Matrix multiplication is generally not commutative. That is A*B ≠ B*A, in general.

    .

    Watch this video about multiplying matrices:

    Matlab Video Tutorial: Multiplying Matrices and Vectors, https://www.youtube.com/watch?v=sgzFn42jU6Y

    .

    Example \(\PageIndex{1}\) Matrix Multiply 3x3 times a vector

    A = [3 2 1;

    2 1 0

    1 0 -1]

    B = [4

    5

    6]

    A*B

    Solution

    A*B =

    28
    13
    -2

    % = [28 %(28 = 3*4 + 2*5 + 1*6)

    % 13 %(13 = 2*4 + 1*5 + 0*6)

    % -2] %(-2 = 1*4 + 0*5 + -1*6)

    .

    Exercise \(\PageIndex{1}\) Matrix Multiplication True/False

    1. True or False: These 2 matrices (which have 3 rows and 2 columns) can be multiplied together:

    [ 1 5 ] [ 9 5 ]

    A = | 2 9 | B = | 8 9 |

    [ 3 4 ] [ 7 5 ]

    2. True or False: These 2 matrices can be multiplied together:

    [ 1 5 ]

    A = | 2 9 |; B = [ 1 3 2 ]

    [ 3 4 ] [ 4 6 9 ]

    Answer

    1. No, because the number of columns in A (2) does not equal the number of rows in B (3).

    1. Yes, because the number of columns in A (2) does equal the number of rows in B (2).

    Exercise \(\PageIndex{2}\) Matrix Multiplication Calculation

    1. What is A*B ?

    A = [1 4
    3 -5]

    B = [ 2 12

    3 1]

    (Do a matrix multiply, not an element-by element multiply)

    Answer

    A*B = [14 16

    -9 31]

    .

    A matrix with ones on the diagonal and zeros elsewhere is called the Identity matrix:

    I = eye(3) = [1 0 0

    0 1 0

    0 0 1]

    I*A = A

    A*I = A

    For more information, see: https://en.Wikipedia.org/wiki/Matrix_multiplication

    .


    This page titled 12.1: Basic Matrix Multiplication is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Carey Smith.