Tutorials › Statistical Theory I - Probability and Distribution Theory › Equality Cases in Cauchy–Schwarz

Moment Inequalities and Jensen · Tutorial 379 of 994

Equality Cases in Cauchy–Schwarz

Learn when equality in Cauchy–Schwarz forces an almost-sure linear relation, and how to check that condition in concrete examples.

Intermediate 9 min read

What You'll Learn

  • State the equality condition for the random-variable Cauchy–Schwarz inequality, including zero second moments.
  • Prove the condition using the mean-square residual between two variables.
  • Distinguish equality for raw variables from equality for centered variables.
  • Check equality and strict inequality by calculating moments and testing almost-sure linear dependence.
  • Interpret equality in the covariance bound and identify common reasoning errors.

Why Equality Requires More Than Matching Moments

Cauchy–Schwarz bounds the magnitude of a product expectation by the product of two second-moment sizes. Equality is a much sharper statement: apart from cases where one variable is zero almost surely, it says that one random variable is a fixed multiple of the other, almost surely. The multiplier must be a constant, not a random quantity, and the relation must hold outside an event of probability zero.

This condition can be easy to overlook. A large correlation, a zero product expectation, or a relationship that holds for some possible values does not by itself establish equality. The decisive question is whether the two variables lie on the same fixed line through the origin with probability one.

Definition: Random variables \(X\) and \(Y\) are linearly dependent almost surely if there are constants \(a,b\), not both zero, such that \(aX+bY=0\) almost surely. Equivalently, one variable is a fixed constant multiple of the other almost surely, allowing either variable to be zero almost surely.

The Equality Characterization

Suppose \(E[X^2]\) and \(E[Y^2]\) are finite. Then \(E[XY]\) is also finite, and the random-variable Cauchy–Schwarz inequality states \(|E[XY]|\leq \sqrt{E[X^2]E[Y^2]}\). The following result identifies exactly when its two sides agree.

Theorem: Let \(X\) and \(Y\) be random variables with \(E[X^2]<\infty\) and \(E[Y^2]<\infty\). Equality holds in \[ |E[XY]|=\sqrt{E[X^2]E[Y^2]} \] if and only if \(X\) and \(Y\) are linearly dependent almost surely. If both second moments are positive, this is equivalent to \(Y=cX\) almost surely for some nonzero constant \(c\). In that case \(c>0\) gives \(E[XY]=\sqrt{E[X^2]E[Y^2]}\), while \(c<0\) gives \(E[XY]=-\sqrt{E[X^2]E[Y^2]}\).

The assumptions matter: finite second moments ensure the quantities in the claim are defined and finite. The almost-sure qualifier also matters. Equality does not require a relation at every point in the sample space, only outside a set of probability zero.

Proof by a Mean-Square Residual

The proof measures how far \(X\) is from being a fixed multiple of \(Y\). A nonnegative square has expectation zero exactly when that square is zero almost surely, so this residual detects the required relation.

1
Handle a zero second moment.
If \(E[Y^2]=0\), nonnegativity of \(Y^2\) implies \(Y=0\) almost surely. Thus \(E[XY]=0\), and both sides of the equality are zero. Also \(Y=0\cdot X\) almost surely, so the variables are linearly dependent. The same reasoning applies if \(E[X^2]=0\).
2
Choose the best constant multiple.
Now suppose \(E[Y^2]>0\), and set \(t=E[XY]/E[Y^2]\). The square \((X-tY)^2\) is integrable, and expansion gives \(E[(X-tY)^2]=E[X^2]-E[XY]^2/E[Y^2]\).
3
Read off equality.
Multiplying the residual identity by \(E[Y^2]\) shows that \(E[XY]^2=E[X^2]E[Y^2]\) exactly when \(E[(X-tY)^2]=0\). A nonnegative random variable with expectation zero is zero almost surely, so this occurs exactly when \(X=tY\) almost surely.

For completeness, if \(E[(X-tY)^2]=0\), nonnegativity implies \((X-tY)^2=0\) almost surely, hence \(X=tY\) almost surely. Conversely, if \(X=tY\) almost surely, then \(E[XY]=tE[Y^2]\) and \(E[X^2]=t^2E[Y^2]\), so \(E[XY]^2=E[X^2]E[Y^2]\). If both second moments are positive, \(t\) cannot be zero. This proves the stated equivalence, including the nondegenerate case. \(\square\)

Worked Examples

Worked Example: A Negative Multiple Gives the Lower Endpoint

Let \(X\) take the values \(-1\) and \(1\), each with probability \(1/2\), and let \(Y=-3X\). Check whether equality holds and determine its sign.

Since \(X^2=1\) in either outcome, \(E[X^2]=1\). Also \(Y^2=9X^2=9\), so \(E[Y^2]=9\). Finally, \(XY=-3X^2=-3\), giving \(E[XY]=-3\).

Therefore, \[ |E[XY]|=3=\sqrt{1\cdot 9}. \] Equality holds. The relation \(Y=-3X\) holds for every outcome, and its negative multiplier explains why \(E[XY]\) is the negative endpoint, not the positive one.

Worked Example: Positive Moments Do Not Guarantee Equality

Let \(X\) have the uniform distribution on \((-1,1)\) and let \(Y=X^2\). Check whether Cauchy–Schwarz is strict.

For a uniform variable on \((-1,1)\), \(E[X^k]=\frac12\int_{-1}^1 x^k\,dx\) when the moment exists. Thus \(E[X^2]=1/3\) and \(E[Y^2]=E[X^4]=1/5\). Since \(XY=X^3\) is odd, \(E[XY]=0\).

Consequently, \[ |E[XY]|=0<\sqrt{\frac13\cdot\frac15}=\frac{1}{\sqrt{15}}. \] The inequality is strict. Indeed, a relation \(Y=cX\) would require \(X^2=cX\), or \(X(X-c)=0\), almost surely. This equation can hold only when \(X\) equals \(0\) or \(c\). A continuous uniform variable assigns probability zero to this finite set, so no constant \(c\) gives the required almost-sure relation.

Worked Example: Centering Changes the Equality Question

Let \(X\) be Bernoulli with \(P(X=1)=1/4\) and \(P(X=0)=3/4\), and set \(Y=2X+5\). Compare the raw Cauchy–Schwarz inequality with the corresponding covariance inequality.

Because \(X^2=X\), \(E[X^2]=1/4\). The variable \(Y\) is 5 with probability \(3/4\) and 7 with probability \(1/4\), so \(E[Y^2]=(3/4)25+(1/4)49=31\). Also \(XY\) is 0 when \(X=0\) and 7 when \(X=1\), so \(E[XY]=7/4\).

For the raw variables, the two sides are \[ |E[XY]|=\frac74,\qquad \sqrt{E[X^2]E[Y^2]}=\sqrt{\frac{31}{4}}=\frac{\sqrt{31}}{2}. \] The inequality is strict: \(49/16<31/4\), since \(49<124\). In fact, \(Y=2X+5\) is not a relation of the form \(Y=cX\).

Now \(E[X]=1/4\) and \(E[Y]=11/2\). The centered variables satisfy \(Y-E[Y]=2(X-E[X])\) exactly. Their variances and covariance are \[ \operatorname{Var}(X)=\frac{3}{16},\qquad \operatorname{Var}(Y)=4\cdot\frac{3}{16}=\frac34,\qquad \operatorname{Cov}(X,Y)=2\cdot\frac{3}{16}=\frac38. \] Thus \(|\operatorname{Cov}(X,Y)|=3/8=\sqrt{(3/16)(3/4)}\). Equality holds for the centered variables even though it does not hold for the raw variables.

Worked Example: Equality When One Variable Is Zero Almost Surely

Let \(X=0\) almost surely and let \(Y\) have the standard normal distribution. Here \(E[X^2]=0\), \(E[Y^2]=1\), and \(E[XY]=0\). Therefore both sides of the Cauchy–Schwarz equality are zero: \[ |E[XY]|=0=\sqrt{0\cdot 1}. \] Equality holds even though \(Y\) is not a multiple of \(X\) with a nonzero multiplier. The general linear-dependence definition covers this case: \(X=0\cdot Y\) almost surely. This is why a theorem stated only for nonzero second moments needs a separate degenerate case.

Equality for Covariance and Correlation

Applying the same characterization to the centered variables \(X-E[X]\) and \(Y-E[Y]\) gives the equality condition for the covariance bound. Finite variances are the needed moment assumption, because they ensure the centered variables have finite second moments.

Corollary: If \(X\) and \(Y\) have finite variances, then \[ |\operatorname{Cov}(X,Y)|\leq \sqrt{\operatorname{Var}(X)\operatorname{Var}(Y)}. \] Equality holds if and only if the centered variables \(X-E[X]\) and \(Y-E[Y]\) are linearly dependent almost surely. If both variances are positive, this is equivalent to \(Y-E[Y]=c(X-E[X])\) almost surely for a nonzero constant \(c\).

To see this directly, set \(U=X-E[X]\) and \(V=Y-E[Y]\). Then \(E[U]=E[V]=0\), \(E[UV]=\operatorname{Cov}(X,Y)\), \(E[U^2]=\operatorname{Var}(X)\), and \(E[V^2]=\operatorname{Var}(Y)\). The theorem applied to \(U,V\) gives the bound and its equality condition. If both variances are positive, the correlation is defined by dividing the covariance by the product of the standard deviations. It equals \(1\) or \(-1\) exactly when the centered variables have the indicated positive or negative constant-multiple relation.

Common Mistake: Confusing a Linear Relation With an Affine One

A frequent error is to conclude that raw Cauchy–Schwarz is an equality whenever \(Y=aX+b\) almost surely. That is not enough: raw equality requires proportionality through the origin, \(Y=cX\), apart from zero-variable cases. A nonzero intercept generally prevents it. By contrast, the covariance inequality concerns centered variables, so an affine relation between \(X\) and \(Y\) becomes a proportionality after centering.

Another error is to infer equality from \(E[XY]=0\). In the uniform example, the product expectation is zero but both second moments are positive, so the inequality is strict. When both second moments are positive, equality with \(E[XY]=0\) is impossible: its right-hand side is positive. Zero product expectation and equality coincide only in a degenerate case where at least one second moment is zero.

Key takeaway: Check equality by testing for an almost-sure constant-multiple relation between the variables in the inequality. For a covariance inequality, first center both variables; for raw Cauchy–Schwarz, do not subtract their means.

Check Your Understanding

Use the equality condition, including the possibility of a zero second moment, to answer these questions.

  1. If \(Y=4X\) almost surely and \(0<E[X^2]<\infty\), which endpoint of the absolute Cauchy–Schwarz bound does \(E[XY]\) attain?
  2. If \(X\) and \(Y\) both have positive second moments and \(E[XY]=0\), can equality hold? Explain.
  3. Suppose \(Y=3X+2\) almost surely and \(X\) is nonconstant. What relation holds between the centered variables, and why does this not generally establish equality for the raw variables?
  4. What does equality imply about \(X\) and \(Y\) when \(E[X^2]=0\)?
  5. For \(X\) uniform on \((-1,1)\) and \(Y=X^2\), identify the moment that makes the product expectation zero and explain why the inequality is strict.