Search the complete library

What do you want to learn or calculate?

Quick linksAll calculatorsMath subjectsPractice questionsFormula library
← Linear Algebra

The Dot Product

Measure alignment and test orthogonality.

Linear algebra is the math of vectors and matrices. It lets you handle many equations, or many dimensions, all at the same time instead of one line at a time.

The Dot Product: the central idea

The dot product converts two vectors into a scalar measuring directional alignment. Zero indicates perpendicular directions when neither vector is zero.

Words you need

Dot product
The dot product of two vectors is the number you get by multiplying their matching components and adding the results, and it is also equal to the two lengths multiplied by the cosine of the angle between them.
Orthogonal vectors
Two nonzero vectors are orthogonal when their dot product is zero, which is another way of saying they meet at a right angle.
Magnitude
The magnitude of a vector is its length, found by taking the square root of the dot product of the vector with itself.
Unit vector
A unit vector is a vector whose magnitude is exactly 1, and you build one by dividing a vector by its own length so only its direction survives.
Projection
The projection of u onto v is the shadow u casts along the direction of v, and its formula is the dot product of u and v divided by the dot product of v with itself, times v.
Scalar
A scalar is an ordinary single number with no direction attached, which is exactly what a dot product returns, unlike a cross product.

What to know before this lesson

Know vector components, multiplication and addition, vector magnitude, and the cosine of an angle.

If one of those prerequisites is uncertain, use the Linear Algebra subject guide to locate the earlier concept before memorizing a procedure.

The dot product: a worked example

Follow the mathematical structure
$(2,1)\cdot(3,-6)=6-6=0$, so the vectors are orthogonal.

Every step, with the arithmetic

  1. Step 1 - Check both vectors have the same number of componentsu = (3, 4) and v = (4, 3) are both 2-dimensional, so the dot product is defined
  2. Step 2 - Multiply the matching componentsfirst components: 3 x 4 = 12, and second components: 4 x 3 = 12
  3. Step 3 - Add those productsu dot v = 12 + 12 = 24, a single number and not a vector
  4. Step 4 - Find each length with the Pythagorean theoremlength of u = square root of (3^2 + 4^2) = square root of 25 = 5, and the length of v is also 5
  5. Step 5 - Divide to get the cosine of the anglecos(theta) = 24 / (5 x 5) = 24 / 25 = 0.96
  6. Step 6 - Take the inverse cosinetheta = arccos(0.96) is about 16.3 degrees, a small angle, so the vectors nearly point the same way
  7. Step 7 - Test a perpendicular pair(3, 4) dot (-4, 3) = -12 + 12 = 0, so those two meet at exactly 90 degrees
  8. Step 8 - Test an opposite pair(3, 4) dot (-3, -4) = -9 - 16 = -25, which is minus the length of u times the length of v, so the angle is 180 degrees

$(2,1)\cdot(3,-6)=2(3)+1(-6)=0$, so the nonzero vectors meet at a right angle.

What the sign of the dot product says about the angle between two nonzero vectors

What the sign of the dot product says about the angle between two nonzero vectors
Dot productAngle between themWhat the vectors are doingExample
Equal to length times length (largest possible)0 degreesPointing in exactly the same direction(3, 4) dot (6, 8) = 18 + 32 = 50 = 5 x 10
Positive but smaller than thatBetween 0 and 90 degreesLeaning the same general way(3, 4) dot (4, 3) = 12 + 12 = 24
Exactly zeroExactly 90 degreesPerpendicular, also called orthogonal(3, 4) dot (-4, 3) = -12 + 12 = 0
NegativeBetween 90 and 180 degreesLeaning the opposite general way(3, 4) dot (-1, 0) = -3 + 0 = -3
Equal to minus length times length (most negative)180 degreesPointing in exactly opposite directions(3, 4) dot (-3, -4) = -9 - 16 = -25
A vector dotted with itself0 degrees with itselfGives the length squared(3, 4) dot (3, 4) = 9 + 16 = 25 = 5^2

The step-by-step method for the dot product

  1. Confirm both vectors have the same dimension and multiply corresponding components.
  2. Add the component products to obtain the scalar dot product.
  3. Use the sign, zero value, or formula $u\cdot v=\|u\|\|v\|\cos\theta$ to interpret alignment.

How to check your answer

Compute their slopes or use the cosine formula; a zero cosine confirms an angle of $90^\circ$.

Multiply back, inspect dimensions, and test the result on a simple vector. Solutions to a system must satisfy every original equation, not merely the reduced matrix.

A mistake that changes the mathematics

The dot product is a scalar, not a componentwise vector. Componentwise multiplication alone is an unfinished calculation.

Pause before continuing

Explain why the tempting step is invalid, then write the condition or definition that prevents it. This turns the error into a rule you can recognize in a new problem.

Where you will actually use this

Game lighting

A renderer dots the surface normal of a wall with the direction to the lamp; a large positive value means the surface faces the light and is drawn bright, while a value at or below zero means it faces away and stays dark.

Physics work

The work done by a force is the dot product of the force vector and the displacement vector, which is why pushing sideways on a moving cart does no work at all: the dot product is zero.

Recommendation engines

Documents and user tastes are stored as long lists of numbers, and the cosine of the angle between two of those vectors, computed from a dot product, is what ranks how similar they are.

How the dot product connects to the rest of linear algebra

Try a transfer problem

Find the projection of $(4,2)$ onto $(1,1)$ and explain how the dot product determines its signed length.

Show the worked answer

Let u = (4, 2) and v = (1, 1). First compute u dot v = (4)(1) + (2)(1) = 4 + 2 = 6, and v dot v = (1)(1) + (1)(1) = 2. The projection is (u dot v divided by v dot v) times v = (6 / 2)(1, 1) = 3(1, 1) = (3, 3). The dot product supplies the signed length. The length of v is the square root of 2, so the scalar projection, the signed distance along v, is 6 divided by the square root of 2, which is about 4.24, and the vector (3, 3) does have length 3 times the square root of 2, about 4.24. Because the dot product came out positive, that signed length is positive and the shadow falls on the same side as v. If u had been (-4, -2), the dot product would be -6, the projection would be (-3, -3), and the negative sign would tell you the shadow lands behind the starting point. A dot product of 0 would mean u casts no shadow along v at all, since the two would be perpendicular.

Work without copying the example. When finished, use the relevant focused calculator or formula reference to check the setup and result, then correct the first line where your reasoning changed. When the method feels reliable, move to linear algebra practice questions.

Questions about the dot product

What does it mean when the dot product is zero?

If neither vector is the zero vector, it means they are perpendicular, since cosine of 90 degrees is 0. That is the fastest orthogonality test there is: (3, 4) dot (-4, 3) = -12 + 12 = 0, so those directions meet at a right angle without you ever computing an angle. The zero vector dots to 0 with everything, which is why it is excluded.

What is the difference between the dot product and the cross product?

The dot product takes two vectors and returns a single number that measures alignment, and it works in any number of dimensions. The cross product takes two 3-dimensional vectors and returns a new vector perpendicular to both, measuring how much they spread apart. Alignment versus perpendicularity, number versus vector.

Can a dot product be negative, and what does that mean?

Yes. A negative dot product means the angle between the vectors is more than 90 degrees, so they lean in generally opposite directions. (3, 4) dot (-1, 0) = -3 says the second vector points somewhat against the first. The most negative value possible is minus the product of the two lengths, which happens at exactly 180 degrees.

Why does a vector dotted with itself give its length squared?

Because the components multiply against themselves: (3, 4) dot (3, 4) = 3 squared plus 4 squared = 25, which is exactly the Pythagorean sum under the square root in the length formula. It also matches the angle formula, since the angle between a vector and itself is 0 degrees and cosine of 0 is 1, leaving length times length.

Stuck on a problem?

Stuck on a the dot product problem?

Paste your own question, or send the transfer problem above. You get the method, the answer, and a check you can repeat yourself.