Cauchy-Schwarz Inequality Calculator
Compute the Cauchy-Schwarz inequality for two 3D vectors: dot product, norms, angle, slack.
Verify that |u dot v| is at most ||u|| times ||v||.
The Cauchy-Schwarz inequality is the single most reused result in linear algebra and probability:
|⟨u, v⟩| ≤ ||u|| · ||v||
For two real vectors u and v, the absolute value of their dot product is at most the product of their magnitudes. Square both sides and the equivalent finite-sum form falls out:
(Σ uᵢvᵢ)² ≤ (Σ uᵢ²)(Σ vᵢ²)
Equality holds if and only if one vector is a scalar multiple of the other (they’re parallel or anti-parallel). For any other pair of vectors, there’s strictly more on the right than on the left, and the size of that gap measures how much the vectors deviate from being parallel.
Why this matters. The whole concept of “angle between vectors in high dimensions” rests on Cauchy-Schwarz. Without it, the definition cos θ = u·v / (||u|| ||v||) might give a value outside [−1, 1], which would not be the cosine of anything. Cauchy-Schwarz is exactly the guarantee that the ratio stays in [−1, 1], so the inverse cosine returns a real angle.
Real-world applications:
- Pearson correlation in statistics is just u·v / (||u|| ||v||) computed on mean-centred data vectors. Cauchy-Schwarz is the reason correlation always sits between −1 and 1.
- Cosine similarity in machine learning (recommendation engines, search ranking, semantic embeddings) is the same ratio. When a search engine ranks documents by relevance to a query, it’s often computing u·v / (||u|| ||v||) between embedding vectors.
- The triangle inequality ||u + v|| ≤ ||u|| + ||v|| follows directly from Cauchy-Schwarz applied to ||u + v||² = ||u||² + 2⟨u, v⟩ + ||v||².
- The Heisenberg uncertainty principle in quantum mechanics is a Cauchy-Schwarz statement applied to position and momentum operators acting on wavefunctions.
Historical note. Augustin-Louis Cauchy proved it for finite sums in his 1821 Cours d’Analyse. Viktor Bunyakovsky extended it to integrals in 1859. Hermann Schwarz gave a generalised proof in 1888. In Russian and German textbooks it’s often called the Cauchy-Bunyakovsky-Schwarz inequality (CBS).
Worked example. Take u = (1, 2, 3) and v = (4, 5, 6). The dot product u·v = 4 + 10 + 18 = 32. So (u·v)² = 1024. The squared norms: ||u||² = 1 + 4 + 9 = 14, ||v||² = 16 + 25 + 36 = 77. Product 14 × 77 = 1078. Since 1024 < 1078, the inequality holds strictly. The slack ratio 1024 / 1078 ≈ 0.9499, which equals cos²θ. So θ = arccos(√0.9499) ≈ 12.93°. The two vectors point in similar but not identical directions.
Equality case. Take u = (2, 4) and v = (3, 6). Here v = 1.5 u, so they’re parallel. u·v = 6 + 24 = 30. (u·v)² = 900. ||u||² = 20, ||v||² = 45, product 900. Equality holds exactly, which means the vectors are parallel.
Quick check. If you enter the same vector twice (u = v), the inequality becomes ||u||⁴ ≤ ||u||² · ||u||², which is equality (slack ratio = 1). If you enter orthogonal vectors like u = (1, 0, 0) and v = (0, 1, 0), the dot product is zero, slack ratio is zero, and angle is 90°.