Skip to main content
Library homepage
 
Engineering LibreTexts

11.7: Dot Product

  • Page ID
    88002
  • \( \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

      The dot product is the sum of the products of the corresponding elements of 2 vectors. Both vectors have to be the same length. Geometrically, it is the product of the magnitudes of the two vectors and the cosine of the angle between them.

      The dot product of a vector with itself is the sum of the squares of the vector's elements. The vector's magnitude (length) is the square root of the dot product of the vector with itself.

      This video gives details about dot product:

      .

      Here are examples illustrating the cases of parallel vectors, perpendicular vectors (a.k.a orthogonal), and vectors at 60 degrees relative to each other.

      Example \(\PageIndex{1}\) Use dot() to compute the magnitude of a vector

      a = [1 2 3];
      a_dot_a = dot(a,a) % This is the sum of the squares of the elements of A
      % 14
      a_mag = sqrt(a_dot_a)
      % 3.7417

      MATLAB also has this function to compute the magnitude of a vector:

      a_mag = norm(a)

      The norm function computes the square root of the sum of the squares of the elements of the vector.

      Solution

      Add example text here.

      The dot product of 2 different vectors is equivalent to the product of each vector's magnitude (length) times the cos(angle between the 2 vectors).
      When the vectors are parallel, the cos = 1, so the dot product = the product of their magnitudes.
      When the vectors are perpendicular, the cos = 0, so the dot product = 0.

      Example \(\PageIndex{2}\) dot(a,b), a & b parallel

      a = [1 2 3];
      b = 2*a % = [2 4 6]
      ab_dot = dot(a,b)
      % = 1*2 + 2*4 + 3*6 = 28
      |a| = sqrt(1^2 + 2^2 +3^2) = sqrt(14)
      |b| = 2*|a| = 2*sqrt(14)
      |a|*|b| = 2*14 = 28

      Solution

      Add example text here.

      .

      Example \(\PageIndex{3}\) dot(c1,d1), c1 & d1 perpendicular: 0 & 90 degs

      c1 = [1 0 0] % 0 degs
      d1 = [0 1 0] % 45 degs
      cd1_dot = dot(c1,d1)
      % = 0, so these are perpendicular

      Solution

      Add example text here.

      .

      Example \(\PageIndex{4}\) dot(c2,d2), c2 & d2 perpendicular: +/- 45 degs

      c2 = [ 1 1 0] % at 45 degs
      d2 = [ 1 -1 0] % at -45 degs
      cd2_dot = dot(c2,d2)
      % = 0, so these are perpendicular

      Solution

      Add example text here.

      .

      Example \(\PageIndex{5}\) dot(e1,f1), unit vectors at 0 & 60 degrees

      e1 = [ 1 0 0] % unit vector at 0 degs
      f1 = [ cosd(60) sind(60) 0] % unit vector at 60 degs
      % f1 = [0.500 0.866 0]
      ef1_dot = dot(e1,f1)
      % = 0.500 = cosd(60)

      Solution

      Add example text here.

      .

      Example \(\PageIndex{6}\) Not unit vectors at 0 & 60 degrees

      e2 = 2*[ 1 0 0] % at 0 degs
      e2_mag = sqrt(dot(e2,e2)) % = 2
      f2 = 5*[ cosd(60) sind(60) 0] % at 60 degs
      f2_mag = sqrt(dot(f2,f2)) % = 5

      % When they are not unit vectors, we need to divide by their magnitudes.
      cos_ef = dot(e2,f2) / (e2_mag*f2_mag)
      % = 0.5 = cos(60)

      Solution

      Add example text here.

      .

      .


      This page titled 11.7: Dot Product is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Carey Smith.

      • Was this article helpful?