Euler Hall — free maths guides

Compute a dot product

Multiply matching entries of two vectors and add the products. The idea in plain words, a worked example, and a check with the answers shown — part of the free Linear Algebra guides.

The whole skill in one line

Multiply matching entries, then add. That is the dot product.

u⋅w  =  u1w1+u2w2+⋯+unwn.u\cdot w \;=\; u_1w_1+u_2w_2+\cdots+u_nw_n.

The result is one number. Not a vector, not a matrix — a single scalar.

Every geometric idea in this course — length, angle, perpendicularity, projection, least squares — is computed from this one number. It is worth being able to do it without thinking.

Why it is defined this way and why order matters for the pairing

Nothing about the definition is arbitrary. The pairinguiwiu_iw_i matches entryii with entryii because both vectors are written in the same coordinate system: entry11 is the component along the first axis in each vector, so multiplying them multiplies the two "amounts along the same axis".

That is also why the two vectors must have the same number of entries. A component along a third axis has nothing to pair with in a 2-vector, so "the dot product of a 2-vector and a 3-vector" is not defined — and padding one with a zero does not rescue it, because the padded vector is a different vector from the one asked about.

The addition at the end is what turns a list of products into a single number. That is the step people skip when they are moving fast, and it is the whole point of the operation.

Worked example in three dimensions, then five

Three dimensions.u=(1,3,2)u=(1,3,2),w=(4,−4,4)w=(4,-4,4):

u⋅w=(1)(4)+(3)(−4)+(2)(4)=4−12+8=0.u\cdot w = (1)(4)+(3)(-4)+(2)(4) = 4-12+8 = 0.

A zero total. In the next lesson that will mean these two vectors meet at a right angle; for now the point is only the arithmetic, including the−12-12.

Five dimensions.u=(1,−2,0,3,1)u=(1,-2,0,3,1),w=(4,1,5,−1,2)w=(4,1,5,-1,2):

u⋅w=4−2+0−3+2=1.u\cdot w = 4-2+0-3+2 = 1.

Five products, one sum, one number. The dimension changes how many terms there are; it never changes the shape of the answer.

By the end you can
  • Multiply matching entries of two vectors and add the products
  • Keep every product's own sign; only the addition is unsigned
  • Recognise that the result is a single number, not a vector or a matrix
  • Apply the same definition in any dimension, from 2 upward
Check yourself

(a)u=(1,−2,3)u=(1,-2,3),w=(4,5,−6)w=(4,5,-6). Computeu⋅wu\cdot w.

(b) Why isu⋅wu\cdot w undefined foru∈R3u\in\mathbb{R}^3 andw∈R2w\in\mathbb{R}^2?

(c)u⋅u=0u\cdot u=0 for some vectoruu. What mustuu be?

Answers

(a)4−10−18=−244-10-18=-24.

(b) There is no third pair to multiply. The definition pairs entryii with entryii, and a 2-vector has no entry33 to pair with the 3-vector's third entry. Padding with a zero would be computing a different product, between different vectors.

(c)u=0u=\mathbf{0}. The self-product is a sum of squaresu12+⋯+un2u_1^2+\cdots+u_n^2, and a sum of squares is zero only when every term is zero.

Work out where to start — free, no accountAnswer six real questions — free, no account