# Cauchy–Schwarz inequality

The Cauchy–Schwarz inequality (also called Cauchy–Bunyakovsky–Schwarz inequality) is an upper bound on the inner product between two vectors in an inner product space in terms of the product of the vector norms. It is considered one of the most important and widely used inequalities in mathematics.
Inner products of vectors can describe finite sums (via finite-dimensional vector spaces), infinite series (via vectors in sequence spaces), and integrals (via vectors in Hilbert spaces). The inequality for sums was published by Augustin-Louis Cauchy (1821). The corresponding inequality for integrals was published by Viktor Bunyakovsky (1859) and Hermann Schwarz (1888). Schwarz gave the modern proof of the integral version.

## Statement of the inequality

The Cauchy–Schwarz inequality states that for all vectors $\mathbf {u}$ and $\mathbf {v}$ of an inner product space
where $\langle \cdot ,\cdot \rangle$ is the inner product. Examples of inner products include the real and complex dot product; see the examples in inner product. Every inner product gives rise to a Euclidean $\ell _{2}$ norm, called the canonical or induced norm, where the norm of a vector $\mathbf {u}$ is denoted and defined by $\|\mathbf {u} \|:={\sqrt {\langle \mathbf {u} ,\mathbf {u} \rangle }},$ where $\langle \mathbf {u} ,\mathbf {u} \rangle$ is always a non-negative real number (even if the inner product is complex-valued). By taking the square root of both sides of the above inequality, the Cauchy–Schwarz inequality can be written in its more familiar form in terms of the norm:
Moreover, the two sides are equal if and only if $\mathbf {u}$ and $\mathbf {v}$ are linearly dependent.

## Special cases
### Sedrakyan's lemma – positive real numbers

Sedrakyan's inequality, also known as Bergström's inequality, Engel's form, Titu's lemma (or the T2 lemma), states that for real numbers $u_{1},u_{2},\dots ,u_{n}$ and positive real numbers $v_{1},v_{2},\dots ,v_{n}$: ${\frac {\left(u_{1}+u_{2}+\cdots +u_{n}\right)^{2}}{v_{1}+v_{2}+\cdots +v_{n}}}\leq {\frac {u_{1}^{2}}{v_{1}}}+{\frac {u_{2}^{2}}{v_{2}}}+\cdots +{\frac {u_{n}^{2}}{v_{n}}},$ or, using summation notation, ${\biggl\sum _{i=1}^{n}u_{i}{\biggr )}^{2}{\bigg /}\sum _{i=1}^{n}v_{i}\,\leq \,\sum _{i=1}^{n}{\frac {u_{i}^{2}}{v_{i}}}.$
It is a direct consequence of the Cauchy–Schwarz inequality, obtained by using the dot product on $\mathbb {R} ^{n}$ upon substituting $u_{i}'={\frac {u_{i}}{\sqrt {v_{i}{\vphantom {t}}}}}$ and $v_{i}'={\textstyle {\sqrt {v_{i}{\vphantom {t}}}}}$. This form is especially helpful when the inequality involves fractions where the numerator is a perfect square.

### R$^2$ - The plane

The real vector space $\mathbb {R} ^{2}$ denotes the 2-dimensional plane. It is also the 2-dimensional Euclidean space where the inner product is the dot product. If $\mathbf {u} =(u_{1},u_{2})$ and $\mathbf {v} =(v_{1},v_{2})$ then the Cauchy–Schwarz inequality becomes: $\langle \mathbf {u} ,\mathbf {v} \rangle ^{2}={\bigl\|\mathbf {u} \|\|\mathbf {v} \|\cos \theta {\bigr )}^{2}\leq \|\mathbf {u} \|^{2}\|\mathbf {v} \|^{2},$ where $\theta$ is the angle between $\mathbf {u}$ and $\mathbf {v}$.
The form above is perhaps the easiest in which to understand the inequality, since the square of the cosine can be at most 1, which occurs when the vectors are in the same or opposite directions. It can also be restated in terms of the vector coordinates $u_{1}$, $u_{2}$, $v_{1}$, and $v_{2}$ as $\left(u_{1}v_{1}+u_{2}v_{2}\right)^{2}\leq \left(u_{1}^{2}+u_{2}^{2}\right)\left(v_{1}^{2}+v_{2}^{2}\right),$ where equality holds if and only if the vector $\left(u_{1},u_{2}\right)$ is in the same or opposite direction as the vector $\left(v_{1},v_{2}\right)$, or if one of them is the zero vector.

### R$^n$: n-dimensional Euclidean space

In Euclidean space $\mathbb {R} ^{n}$ with the standard inner product, which is the dot product, the Cauchy–Schwarz inequality becomes: ${\biggl\sum _{i=1}^{n}u_{i}v_{i}{\biggr )}^{2}\leq {\biggl\sum _{i=1}^{n}u_{i}^{2}{\biggr )}{\biggl\sum _{i=1}^{n}v_{i}^{2}{\biggr )}.$
The Cauchy–Schwarz inequality can be proved using only elementary algebra in this case by observing that the difference of the right and the left hand side is ${\tfrac {1}{2}}\sum _{i=1}^{n}\sum _{j=1}^{n}(u_{i}v_{j}-u_{j}v_{i})^{2}\geq 0$
or by considering the following quadratic polynomial in $x$ $(u_{1}x+v_{1})^{2}+\cdots +(u_{n}x+v_{n})^{2}={\biggl\sum _{i}u_{i}^{2}{\biggr )}x^{2}+2{\biggl\sum _{i}u_{i}v_{i}{\biggr )}x+\sum _{i}v_{i}^{2}.$
Since the latter polynomial is nonnegative, it has at most one real root, hence its discriminant is less than or equal to zero. That is, ${\biggl\sum _{i}u_{i}v_{i}{\biggr )}^{2}-{\biggl\sum _{i}{u_{i}^{2}}{\biggr )}{\biggl\sum _{i}{v_{i}^{2}}{\biggr )}\leq 0.$

### C$^n$: n-dimensional complex space

If $\mathbf {u} ,\mathbf {v} \in \mathbb {C} ^{n}$ with $\mathbf {u} =(u_{1},\ldots ,u_{n})$ and $\mathbf {v} =(v_{1},\ldots ,v_{n})$ (where $u_{1},\ldots ,u_{n}\in \mathbb {C}$ and $v_{1},\ldots ,v_{n}\in \mathbb {C}$) and if the inner product on the vector space $\mathbb {C} ^{n}$ is the canonical complex inner product (defined by $\langle \mathbf {u} ,\mathbf {v} \rangle :=u_{1}{\overline {v_{1}}}+\cdots +u_{n}{\overline {v_{n}}},$ where the bar notation is used for complex conjugation), then the inequality may be restated more explicitly as follows: ${\bigl |}\langle \mathbf {u} ,\mathbf {v} \rangle {\bigr |}^{2}={\Biggl |}\sum _{k=1}^{n}u_{k}{\bar {v}}_{k}{\Biggr |}^{2}\leq \langle \mathbf {u} ,\mathbf {u} \rangle \langle \mathbf {v} ,\mathbf {v} \rangle ={\biggl\sum _{k=1}^{n}u_{k}{\bar {u}}_{k}{\biggr )}{\biggl\sum _{k=1}^{n}v_{k}{\bar {v}}_{k}{\biggr )}=\sum _{j=1}^{n}|u_{j}|^{2}\sum _{k=1}^{n}|v_{k}|^{2}.$
That is, ${\bigl |}u_{1}{\bar {v}}_{1}+\cdots +u_{n}{\bar {v}}_{n}{\bigr |}^{2}\leq {\bigl|u_{1}|^{2}+\cdots +|u_{n}|^{2}{\bigr )}{\bigl|v_{1}|^{2}+\cdots +|v_{n}|^{2}{\bigr )}.$

### L$^2$

For the inner product space of square-integrable complex-valued functions, the following inequality holds. $\left|\int _{\mathbb {R} ^{n}}f(x){\overline {g(x)}}\,dx\right|^{2}\leq \int _{\mathbb {R} ^{n}}{\bigl |}f(x){\bigr |}^{2}\,dx\int _{\mathbb {R} ^{n}}{\bigl |}g(x){\bigr |}^{2}\,dx.$
The Hölder inequality is a generalization of this.

## Applications
### Analysis

In any inner product space, the triangle inequality is a consequence of the Cauchy–Schwarz inequality, as is now shown: ${\begin{alignedat}{4}\|\mathbf {u} +\mathbf {v} \|^{2}&=\langle \mathbf {u} +\mathbf {v} ,\mathbf {u} +\mathbf {v} \rangle &&\\&=\|\mathbf {u} \|^{2}+\langle \mathbf {u} ,\mathbf {v} \rangle +\langle \mathbf {v} ,\mathbf {u} \rangle +\|\mathbf {v} \|^{2}~&&~{\text{ where }}\langle \mathbf {v} ,\mathbf {u} \rangle ={\overline {\langle \mathbf {u} ,\mathbf {v} \rangle }}\\&=\|\mathbf {u} \|^{2}+2\operatorname {Re} \langle \mathbf {u} ,\mathbf {v} \rangle +\|\mathbf {v} \|^{2}&&\\&\leq \|\mathbf {u} \|^{2}+2|\langle \mathbf {u} ,\mathbf {v} \rangle |+\|\mathbf {v} \|^{2}&&\\&\leq \|\mathbf {u} \|^{2}+2\|\mathbf {u} \|\|\mathbf {v} \|+\|\mathbf {v} \|^{2}~&&~{\text{ using CS}}\\&={\bigl\|\mathbf {u} \|+\|\mathbf {v} \|{\bigr )}^{2}.&&\end{alignedat}}$
Taking square roots gives the triangle inequality: $\|\mathbf {u} +\mathbf {v} \|\leq \|\mathbf {u} \|+\|\mathbf {v} \|.$
The Cauchy–Schwarz inequality is used to prove that the inner product is a continuous function with respect to the topology induced by the inner product itself.

### Geometry

The Cauchy–Schwarz inequality allows one to extend the notion of "angle between two vectors" to any real inner-product space by defining: $\cos \theta _{\mathbf {u} \mathbf {v} }={\frac {\langle \mathbf {u} ,\mathbf {v} \rangle }{\|\mathbf {u} \|\|\mathbf {v} \|}}.$
The Cauchy–Schwarz inequality proves that this definition is sensible, by showing that the right-hand side lies in the interval [−1, 1] and justifies the notion that (real) Hilbert spaces are simply generalizations of the Euclidean space. It can also be used to define an angle in complex inner-product spaces, by taking the absolute value or the real part of the right-hand side, as is done when extracting a metric from quantum fidelity.

### Probability theory

Let $X$ and $Y$ be random variables. Then the covariance inequality is given by: $\operatorname {Var} (X)\geq {\frac {\operatorname {Cov} (X,Y)^{2}}{\operatorname {Var} (Y)}}.$
After defining an inner product on the set of random variables using the expectation of their product, $\langle X,Y\rangle :=\operatorname {E} (XY),$ the Cauchy–Schwarz inequality becomes ${\bigl |}\operatorname {E} (XY){\bigr |}^{2}\leq \operatorname {E} (X^{2})\operatorname {E} (Y^{2}).$
To prove the covariance inequality using the Cauchy–Schwarz inequality, let $\mu =\operatorname {E} (X)$ and $\nu =\operatorname {E} (Y),$ then ${\begin{aligned}{\bigl |}\operatorname {Cov} (X,Y){\bigr |}^{2}&={\bigl |}\operatorname {E} ((X-\mu )(Y-\nu )){\bigr |}^{2}\\&={\bigl |}\langle X-\mu ,Y-\nu \rangle {\bigr |}^{2}\\&\leq \langle X-\mu ,X-\mu \rangle \langle Y-\nu ,Y-\nu \rangle \\&=\operatorname {E} \left((X-\mu )^{2}\right)\operatorname {E} \left((Y-\nu )^{2}\right)\\&=\operatorname {Var} (X)\operatorname {Var} (Y),\end{aligned}}$ where $\operatorname {Var}$ denotes variance and $\operatorname {Cov}$ denotes covariance.

## Proofs

There are many different proofs of the Cauchy–Schwarz inequality other than those given below. When consulting other sources, there are often two sources of confusion. First, some authors define ⟨⋅,⋅⟩ to be linear in the second argument rather than the first. Second, some proofs are only valid when the field is $\mathbb {R}$ and not $\mathbb {C} .$
This section gives two proofs of the following theorem:
Cauchy–Schwarz inequality — Let $\mathbf {u}$ and $\mathbf {v}$ be arbitrary vectors in an inner product space over the scalar field $\mathbb {F} ,$ where $\mathbb {F}$ is the field of real numbers $\mathbb {R}$ or complex numbers $\mathbb {C} .$ Then
with equality holding in the Cauchy–Schwarz Inequality if and only if $\mathbf {u}$ and $\mathbf {v}$ are linearly dependent.
Moreover, if $\left|\langle \mathbf {u} ,\mathbf {v} \rangle \right|=\|\mathbf {u} \|\|\mathbf {v} \|$ and $\mathbf {v} \neq \mathbf {0}$ then $\mathbf {u} ={\frac {\langle \mathbf {u} ,\mathbf {v} \rangle }{\|\mathbf {v} \|^{2}}}\mathbf {v} .$
In both of the proofs given below, the proof in the trivial case where at least one of the vectors is zero (or equivalently, in the case where $\|\mathbf {u} \|\|\mathbf {v} \|=0$) is the same. It is presented immediately below only once to reduce repetition. It also includes the easy part of the proof of the Equality Characterization given above; that is, it proves that if $\mathbf {u}$ and $\mathbf {v}$ are linearly dependent then ${\bigl |}\langle \mathbf {u} ,\mathbf {v} \rangle {\bigr |}=\|\mathbf {u} \|\|\mathbf {v} \|.$
Consequently, the Cauchy–Schwarz inequality only needs to be proven only for non-zero vectors and also only the non-trivial direction of the Equality Characterization must be shown.

### Proof via the Pythagorean theorem

The special case of $\mathbf {v} =\mathbf {0}$ was proven above so it is henceforth assumed that $\mathbf {v} \neq \mathbf {0} .$ Let $\mathbf {z} :=\mathbf {u} -{\frac {\langle \mathbf {u} ,\mathbf {v} \rangle }{\langle \mathbf {v} ,\mathbf {v} \rangle }}\mathbf {v} .$
It follows from the linearity of the inner product in its first argument that: $\langle \mathbf {z} ,\mathbf {v} \rangle =\left\langle \mathbf {u} -{\frac {\langle \mathbf {u} ,\mathbf {v} \rangle }{\langle \mathbf {v} ,\mathbf {v} \rangle }}\mathbf {v} ,\mathbf {v} \right\rangle =\langle \mathbf {u} ,\mathbf {v} \rangle -{\frac {\langle \mathbf {u} ,\mathbf {v} \rangle }{\langle \mathbf {v} ,\mathbf {v} \rangle }}\langle \mathbf {v} ,\mathbf {v} \rangle =0.$
Therefore, $\mathbf {z}$ is a vector orthogonal to the vector $\mathbf {v}$ (Indeed, $\mathbf {z}$ is the projection of $\mathbf {u}$ onto the plane orthogonal to $\mathbf {v} .$) We can thus apply the Pythagorean theorem to $\mathbf {u} ={\frac {\langle \mathbf {u} ,\mathbf {v} \rangle }{\langle \mathbf {v} ,\mathbf {v} \rangle }}\mathbf {v} +\mathbf {z}$ which gives $\|\mathbf {u} \|^{2}=\left|{\frac {\langle \mathbf {u} ,\mathbf {v} \rangle }{\langle \mathbf {v} ,\mathbf {v} \rangle }}\right|^{2}\|\mathbf {v} \|^{2}+\|\mathbf {z} \|^{2}={\frac {|\langle \mathbf {u} ,\mathbf {v} \rangle |^{2}}{(\|\mathbf {v} \|^{2})^{2}}}\,\|\mathbf {v} \|^{2}+\|\mathbf {z} \|^{2}={\frac {|\langle \mathbf {u} ,\mathbf {v} \rangle |^{2}}{\|\mathbf {v} \|^{2}}}+\|\mathbf {z} \|^{2}\geq {\frac {|\langle \mathbf {u} ,\mathbf {v} \rangle |^{2}}{\|\mathbf {v} \|^{2}}}.$
The Cauchy–Schwarz inequality follows by multiplying by $\|\mathbf {v} \|^{2}$ and then taking the square root. Moreover, if the relation $\geq$ in the above expression is actually an equality, then $\|\mathbf {z} \|^{2}=0$ and hence $\mathbf {z} =\mathbf {0} ;$ the definition of $\mathbf {z}$ then establishes a relation of linear dependence between $\mathbf {u}$ and $\mathbf {v} .$ The converse was proved at the beginning of this section, so the proof is complete. $\blacksquare$

### Proof by analyzing a quadratic

Consider an arbitrary pair of vectors $\mathbf {u} ,\mathbf {v}$. Define the function $p:\mathbb {R} \to \mathbb {R}$ defined by $p(t)=\langle t\alpha \mathbf {u} +\mathbf {v} ,t\alpha \mathbf {u} +\mathbf {v} \rangle$, where $\alpha$ is a complex number satisfying $|\alpha |=1$ and $\alpha \langle \mathbf {u} ,\mathbf {v} \rangle =|\langle \mathbf {u} ,\mathbf {v} \rangle |$. Such an $\alpha$ exists since if $\langle \mathbf {u} ,\mathbf {v} \rangle =0$ then $\alpha$ can be taken to be 1.
Since the inner product is positive-definite, $p(t)$ only takes non-negative real values. On the other hand, $p(t)$ can be expanded using the bilinearity of the inner product: ${\begin{aligned}p(t)&=\langle t\alpha \mathbf {u} ,t\alpha \mathbf {u} \rangle +\langle t\alpha \mathbf {u} ,\mathbf {v} \rangle +\langle \mathbf {v} ,t\alpha \mathbf {u} \rangle +\langle \mathbf {v} ,\mathbf {v} \rangle \\&=t\alpha t{\overline {\alpha }}\langle \mathbf {u} ,\mathbf {u} \rangle +t\alpha \langle \mathbf {u} ,\mathbf {v} \rangle +t{\overline {\alpha }}\langle \mathbf {v} ,\mathbf {u} \rangle +\langle \mathbf {v} ,\mathbf {v} \rangle \\&=\lVert \mathbf {u} \rVert ^{2}t^{2}+2|\langle \mathbf {u} ,\mathbf {v} \rangle |t+\lVert \mathbf {v} \rVert ^{2}\end{aligned}}$ Thus, $p$ is a polynomial of degree $2$ (unless $\mathbf {u} =0,$ which is a case that was checked earlier). Since the sign of $p$ does not change, the discriminant of this polynomial must be non-positive: $\Delta =4{\bigl\,|\langle \mathbf {u} ,\mathbf {v} \rangle |^{2}-\Vert \mathbf {u} \Vert ^{2}\Vert \mathbf {v} \Vert ^{2}{\bigr )}\leq 0.$ The conclusion follows.
For the equality case, notice that $\Delta =0$ happens if and only if $p(t)={\biglt\Vert \mathbf {u} \Vert +\Vert \mathbf {v} \Vert {\bigr )}^{2}.$ If $t_{0}=-\Vert \mathbf {v} \Vert /\Vert \mathbf {u} \Vert ,$ then $p(t_{0})=\langle t_{0}\alpha \mathbf {u} +\mathbf {v} ,t_{0}\alpha \mathbf {u} +\mathbf {v} \rangle =0,$ and hence $\mathbf {v} =-t_{0}\alpha \mathbf {u} .$

## Generalizations

Various generalizations of the Cauchy–Schwarz inequality exist. Hölder's inequality generalizes it to $L^{p}$ norms. More generally, it can be interpreted as a special case of the definition of the norm of a linear operator on a Banach space (Namely, when the space is a Hilbert space). Further generalizations are in the context of operator theory, e.g. for operator-convex functions and operator algebras, where the domain and/or range are replaced by a C*-algebra or W*-algebra.
An inner product can be used to define a positive linear functional. For example, given a Hilbert space $L^{2}(m),m$ being a finite measure, the standard inner product gives rise to a positive functional $\varphi$ by $\varphi (g)=\langle g,1\rangle .$ Conversely, every positive linear functional $\varphi$ on $L^{2}(m)$ can be used to define an inner product $\langle f,g\rangle _{\varphi }:=\varphi \left(g^{*}f\right),$ where $g^{*}$ is the pointwise complex conjugate of $g.$ In this language, the Cauchy–Schwarz inequality becomes ${\bigl |}\varphi (g^{*}f){\bigr |}^{2}\leq \varphi \left(f^{*}f\right)\varphi \left(g^{*}g\right),$
which extends verbatim to positive functionals on C*-algebras:
Cauchy–Schwarz inequality for positive functionals on C*-algebras — If $\varphi$ is a positive linear functional on a C*-algebra $A,$ then for all $a,b\in A,$ $\left|\varphi \left(b^{*}a\right)\right|^{2}\leq \varphi \left(b^{*}b\right)\varphi \left(a^{*}a\right).$
The next two theorems are further examples in operator algebra.
Kadison–Schwarz inequality (Named after Richard Kadison) — If $\varphi$ is a unital positive map, then for every normal element $a$ in its domain, we have $\varphi (a^{*}a)\geq \varphi \left(a^{*}\right)\varphi (a)$ and $\varphi \left(a^{*}a\right)\geq \varphi (a)\varphi \left(a^{*}\right).$
This extends the fact $\varphi \left(a^{*}a\right)\cdot 1\geq \varphi (a)^{*}\varphi (a)=|\varphi (a)|^{2},$ when $\varphi$ is a linear functional. The case when $a$ is self-adjoint, that is, $a=a^{*},$ is sometimes known as Kadison's inequality.
Cauchy–Schwarz inequality (Modified Schwarz inequality for 2-positive maps) — For a 2-positive map $\varphi$ between C*-algebras, for all $a,b$ in its domain, ${\begin{aligned}\varphi (a)^{*}\varphi (a)&\leq \Vert \varphi (1)\Vert \varphi \left(a^{*}a\right),{\text{ and }}\\[5mu]\Vert \varphi \left(a^{*}b\right)\Vert ^{2}&\leq \Vert \varphi \left(a^{*}a\right)\Vert \cdot \Vert \varphi \left(b^{*}b\right)\Vert .\end{aligned}}$
Another generalization is a refinement obtained by interpolating between both sides of the Cauchy–Schwarz inequality:
Callebaut's Inequality — For reals $0\leq s\leq t\leq 1,$ ${\begin{aligned}{\biggl\sum _{i=1}^{n}a_{i}b_{i}{\biggr )}^{2}~&\leq ~{\biggl\sum _{i=1}^{n}a_{i}^{1+s}b_{i}^{1-s}{\biggr )}{\biggl\sum _{i=1}^{n}a_{i}^{1-s}b_{i}^{1+s}{\biggr )}\\&\leq ~{\biggl\sum _{i=1}^{n}a_{i}^{1+t}b_{i}^{1-t}{\biggr )}{\biggl\sum _{i=1}^{n}a_{i}^{1-t}b_{i}^{1+t}{\biggr )}~\leq ~{\biggl\sum _{i=1}^{n}a_{i}^{2}{\biggr )}{\biggl\sum _{i=1}^{n}b_{i}^{2}{\biggr )}.\end{aligned}}$
This theorem can be deduced from Hölder's inequality. There are also non-commutative versions for operators and tensor products of matrices.
Several matrix versions of the Cauchy–Schwarz inequality and Kantorovich inequality are applied to linear regression models.