Dot product in matrix notation

The transpose of a matrix

Before describing the dot product in matrix notation, we briefly digress to make sure you know what the transpose of a matrix is.

We can transpose a matrix by switching its rows with its columns. We denote the transpose of matrix A by AT . For example, if

A = [          ]
   1  2  3
   4  5  6
then the transpose of A is
AT = ⌊ 1  4 ⌋
⌈      ⌉
  2  5
  3  6.

Since an n-dimensional vector x is represented by an n × 1 column matrix,

x = ⌊     ⌋
  x1
|     |
|| x2  ||
| x3  |
|⌈  ...  |⌉

  xn,
the transpose xT is a 1 × n row matrix
xT = [ x   x   x    ⋅⋅⋅  x  ]
    1   2   3        n.

The dot product as matrix multiplication

Given the rules of matrix multiplication, the product of a 1 × n matrix with an n× 1 matrix is a 1 × 1 matrix, i.e., a scalar. So if we multiply xT (a 1 ×n matrix) with any n-dimensional vector y (viewed as an n × 1 matrix), we end up with a matrix multiplication equivalent to the familiar dot product of x y:

xT y = [                     ]
  x1  x2  x3  ⋅⋅⋅  xn⌊    ⌋
  y1
|| y2 ||
| y  |
||  3. ||
⌈  .. ⌉
  yn = x1y1 + x2y2 + x3y3 + + xnyn = x y.
Although we won’t typically write a dot product as xT y, you may see it elsewhere. Moreover, this dot product forms the building block for the general matrix multiplication.