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):

uv=u1v1+u2v2u \cdot v = u_1 v_1 + u_2 v_2

Multiply matching components and add.

Its geometric meaning is uv=uvcosθ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 uv=0u \cdot v = 0. No angle computation is needed.

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

cosθ=uvuv\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

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

10practice questions
2interactive scenes

Algebra