Engineering Math - Matrix

 

 

 

Vector Multiplication

 

Actually we don't use the term 'Multiplication' to vector (matrix) operation, because it may confuse you with numeric multiplication like '2 x 3' (two times three) or '4 x 6' etc. There is no such a simple multiplication in vector and matrix like this. In vector and matrix, we have a little bit complicated method and these method is usually called in Vector Product (Matrix Product). In addition, there are two different type of product. One is called 'Inner Product' and the other is called 'Cross product'. Refer to Inner Product and Cross Product page for the details.

The two products answer different questions. The inner product tells you how much two vectors point the same way, and its result is a number. The cross product builds a new vector at right angles to both, and its size is an area. I'll use one pair of vectors, a = [1 2 3] and b = [4 5 6], for both products, so you can compare the results directly.

What does the inner product of two vectors give ?

Let's start with the product you will meet most often. The inner product, also called the dot product, multiplies matching elements and adds them up. So two vectors go in and one number comes out.

For two vectors with n elements, the definition is a ⋅ b = a1b1 + a2b2 + ... + anbn. Both vectors must have the same number of elements, but n can be any size. When the vectors are written as columns, the same number is the matrix product aTb, a 1 x n matrix times an n x 1 matrix.

a = [1 2 3],  b = [4 5 6]

a . b = 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32

The number also has a geometric meaning. The inner product equals |a| |b| cos θ, where θ is the angle between the two vectors. In the example, |a| = sqrt(14) = 3.742 and |b| = sqrt(77) = 8.775. So cos θ = 32 / (3.742 x 8.775) = 0.975, and the two vectors are only 12.9 deg apart. The Inner Product page works through this geometry in detail.

  • The result is a scalar : this is why the inner product is also called the scalar product.
  • The sign shows the direction : positive when the angle is under 90 deg, zero when the vectors are perpendicular, and negative when the angle is over 90 deg.
  • The order does not matter : a ⋅ b = b ⋅ a.
  • A vector dotted with itself gives its squared length : a ⋅ a = 1 + 4 + 9 = 14 = |a|2.

What does the cross product of two vectors give ?

The cross product answers a different question. Given two vectors in 3D space, which direction is perpendicular to both of them ? The result is a new vector, so the cross product is also called the vector product.

The cross product is defined only for 3D vectors. For a = [a1 a2 a3] and b = [b1 b2 b3], the definition is a x b = [a2b3 - a3b2, a3b1 - a1b3, a1b2 - a2b1]. Each element leaves out one index and crosses the other two, which is where the name comes from.

a = [1 2 3],  b = [4 5 6]

a x b = [ 2*6 - 3*5 ,  3*4 - 1*6 ,  1*5 - 2*4 ]
      = [ -3 , 6 , -3 ]

You can check the result with the inner product. The dot product of [-3 6 -3] with a is -3 + 12 - 9 = 0, and with b it is -12 + 30 - 18 = 0. So the new vector is perpendicular to both inputs. Its length is sqrt(9 + 36 + 9) = sqrt(54) = 7.348. This equals |a| |b| sin θ = 3.742 x 8.775 x sin 12.9 deg, the area of the parallelogram that a and b span. The Cross Product page shows the determinant form and more examples.

  • The result is a vector : it is perpendicular to both inputs, and its direction follows the right-hand rule.
  • The order matters : b x a = -(a x b). In the example, b x a = [3 -6 3].
  • Parallel vectors give the zero vector : sin 0 = 0, so there is no area and no unique perpendicular direction.
  • The length is an area : |a x b| is the area of the parallelogram spanned by a and b.

How do the two products compare ?

Now let's put the two products side by side. The table below uses the same a and b as the sections above. Notice that the cosine appears in one product and the sine in the other, so together they describe the angle completely.

 

Property

Inner product a ⋅ b

Cross product a x b

Result

scalar

vector

Vector size

any n, same for both

3D only

Geometric value

|a| |b| cos θ

length |a| |b| sin θ

Order of a and b

does not matter

swapping flips the sign

Zero when

a and b are perpendicular

a and b are parallel

Example with [1 2 3] and [4 5 6]

32

[-3 6 -3]

 

A third product often causes confusion here: the outer product. It is written abT, an n x 1 column times a 1 x n row, and its result is an n x n matrix. For the example, the rows of abT are [4 5 6], [8 10 12] and [12 15 18], and every row is a multiple of b, so the matrix has rank 1. The outer product is therefore not the cross product, although some texts use the two names loosely.

The two products also combine. a ⋅ (b x c) takes the cross product first and the inner product second, and gives the volume of the box spanned by three vectors. The Scalar Triple Product page covers it. Projecting one vector onto another uses the inner product, as the Projection onto a Line page shows.

  • Use the inner product to measure alignment : angles, projections, lengths and correlation all come from it.
  • Use the cross product to find a perpendicular direction : surface normals, torque and rotation axes all come from it.
  • Check the output type first : a number, a 3D vector or an n x n matrix tells you which product was used.