Is it well-known by the Cauchy-Schwarz inequality that $$ \langle x, x\rangle \langle y, y\rangle - \langle x, y\rangle^2 \geq 0 $$ for any $x,y\in H$, $H$ being a Hilbert space with real-valued scalars.

When computing the above expression numerically, sometimes it will be negative (in the order of machine precision) due to round-off errors in the subtraction.

Is there an equivalent expression that is always numerically positive? (E.g., something to the power of 2, a norm of a vector etc.)

  • $\begingroup$ I take it that an absolute value will not suffice? You do know that the quantity is nonnegative, so taking an absolute value will not change its true value, but will result in a nonnegative number on the computer. $\endgroup$ – RideTheWavelet Jul 19 '18 at 8:56
  • 2
    $\begingroup$ Or taking the maximum of the computed value and 0? $\endgroup$ – Mees de Vries Jul 19 '18 at 9:45
  • $\begingroup$ Would taking the logarithm work? $\log(\langle x, x\rangle )+ \log(\langle y, y\rangle) - 2\log(\langle x, y\rangle) \geq 0$. This help when the numbers get really small and avoids floating point errors because it is addition and subtraction. $\endgroup$ – Sonal_sqrt Jul 19 '18 at 9:55
  • 1
    $\begingroup$ Why do you care? Is this computation an end in itself, or is it part of a larger computation? $\endgroup$ – awkward Jul 19 '18 at 12:17
  • $\begingroup$ @RideTheWavelet: taking the absolute value is not the best idea. You know that you are tampering the value, i.e. replacing $-\epsilon$ by $\epsilon$, twice the correction achieved with $0$. $\endgroup$ – user65203 Jul 21 '18 at 14:12

There is Lagrange's Identity:

$$\langle x,x \rangle \langle y,y\rangle - \langle x,y \rangle^2 = \sum_{1 \le i < j \le n} (x_i y_j - x_j y_i)^2$$

for $x, y \in \mathbb{R}^n$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.