intro practice · coding problem
Compute a dot product and angle
Given u = [3, 4] and v = [1, 2], compute u·v, ||u||, ||v||, and cos θ between them. State whether the vectors are orthogonal.
The mechanism
A vector is a point and an arrow. The dot product measures alignment (how much one vector projects onto another); orthogonality means zero projection. Most ML objects — embeddings, weights, activations — are vectors living in some space.
Expected evidence
u·v = 11, ||u|| = 5, ||v|| = √5, cos θ = 11/(5√5) ≈ 0.98, not orthogonal.
Try this drill in the practice workspace →
Hints when you need them
- Dot product is sum of element-wise products.
- Orthogonal ⟺ dot product is zero.
Watch for these mistakes
- Confusing dot product with element-wise multiplication
- Treating vectors as scalars when adding dimensions
- Forgetting that dot product is zero for perpendicular vectors