Prove the Cauchy-Schwarz Inequality is an equality if the vectors are linearly dependent.

The Cauchy-Schwarz inequality is as follows: For any $x,y\in\mathbb{R}^n$, $$|x^Ty|\leq||x||_2\cdot||y||_2$$ Equality is satisfied if and only if $x$ and $y$ are linearly dependent.

My Attempt

First, notice that $|x^Ty|=||x||_2||y||_2\cos(\theta)$. Then, the inequality becomes $$|x^Ty|=||x||_2||y||_2\cos(\theta)\leq||x||_2\cdot||y||_2$$ Now note that $|\cos(\theta)|\leq1$ for all values $\theta$. Hence, the inequality holds.

Now to prove that equality holds if and only if the vectors $x$ and $y$ are linearly dependent.

In the first direction, for the inequality to become an equality, we must have that $|\cos(\theta)|=1$. This only happens for $\theta=0$ or $\theta=\pi$. This implies that the two vectors must be parallel with each other, or in other words, they must be linearly dependent. In the other direction, if the two vectors are linearly dependent, then they are scalar multiples of each other. This implies that both vectors point in the same (or opposite) direction (i.e. $\theta=0$ or $\theta=\pi$). Then $|\cos(\theta)|=1$, and so we have equality.

I feel that my explanation for the equality part is inadequate. Could I get some verification on this? Thank you


The statement holds for abstract inner product spaces $(V,\langle .,.\rangle )$. In your case $V = \mathbb{R}^n$ and $\langle u,v\rangle = u^Tv$. We can show it in this particular case:

Suppose $u,v$ are nonzero. We have that $(u-av)^T(u-av)=0$ only if $u=av$ for some $a \in \mathbb{R}$. In general

$$\begin{aligned}0\leq (u-av)^T(u-av) &=u^Tu -2au^Tv+a^2v^Tv \end{aligned}$$

Set $a=(u^Tu)/(u^Tv)$ and we get $(u^Tv)^2\leq (u^Tu)(v^Tv)$. So we get the equality only if $u=av$. On the other hand, if $u=av$, substitute it in the inequality and you get the equality.