Courses / Computer Science I
Algebra

Dot Product and Orthogonality

Computer Science I 191 words Free to read

Multiplying Vectors

The dot product takes two vectors and returns a single number (a scalar). For u=(u1,u2)u = (u_1, u_2) and v=(v1,v2)v = (v_1, v_2):

u⋅v=u1v1+u2v2u \cdot v = u_1 v_1 + u_2 v_2

Multiply matching components and add.

Its geometric meaning is u⋅v=∥u∥∥v∥cos⁡θu \cdot v = \|u\|\|v\|\cos\theta, where θ\theta is the angle between them. It measures how aligned two vectors are:

AlignmentDot ProductAngle θ\theta
Same directionPositiveθ<90∘\theta < 90^\circ
PerpendicularZeroθ=90∘\theta = 90^\circ
OppositeNegativeθ>90∘\theta > 90^\circ
The dot product built from its own components, then read across the

Orthogonality and Angles

Two nonzero vectors are orthogonal (perpendicular) exactly when u⋅v=0u \cdot v = 0. No angle computation is needed.

The dot product recovers length via u⋅u=∥u∥2u \cdot u = \|u\|^2. You can find the angle between vectors using:

cos⁡θ=u⋅v∥u∥∥v∥\cos\theta = \frac{u \cdot v}{\|u\|\|v\|}

In machine learning, cosine similarity uses this exact formula to measure how similar two feature vectors are for search.

Pitfall: The dot product returns a number, never a vector. Orthogonal always means a dot product of zero.

Practise this lesson

Try the questions below, free, answers included. The full set, with its interactive scenes, is in the Tryals app.

10practice questions
2interactive scenes

Algebra