Skip to main content
Mathematics LibreTexts

11.1: Dot Product Review

  • Page ID
    65067
  • \( \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}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    We covered inner products a while ago. This assignment will extend the idea of inner products to matrix multiplication. As a reminder, Sections 1.4 of the Stephen Boyd and Lieven Vandenberghe Applied Linear algebra book covers the dot product. Here is a quick review:

    from IPython.display import YouTubeVideo
    YouTubeVideo("ZZjWqxKqJwQ",width=640,height=360, cc_load_policy=True)

    Given two vectors \(u\) and \(v\) in \(R^n\) (i.e. they have the same length), the “dot” product operation multiplies all of the corresponding elements and then adds them together. Ex:

    \[u = [u_1, u_2, \dots, u_n] \nonumber \]

    \[v = [v_1, v_2, \dots, v_n] \nonumber \]

    \[u \cdot v = u_1 v_1 + u_2 v_2 + \dots + u_nv_n \nonumber \]

    or:

    \[u \cdot v = \sum^n_{i=1} u_i v_i \nonumber \]

    This can easily be written as python code as follows:

    u = [1,2,3]
    v = [3,2,1]
    solution = 0
    for i in range(len(u)):
        solution += u[i]*v[i]
        
    solution
    10

    In numpy the dot product between two vectors can be calculated using the following built in function:

    import numpy as np
    np.dot([1,2,3], [3,2,1])
    10
    Question

    What is the dot product of any vector and the zero vector?

    Question

    What happens to the numpy.dot function if the two input vectors are not the same size?


    This page titled 11.1: Dot Product Review is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?