# Why $\|x\|^2\cdot \|y\|^2-(x\cdot y)^2=\sum_{1\leq i<j\leq n}(x_i y_j-x_j y_i)^2$?

I am reading the proof of Cauchy-Schwarz inequality. It states $$\|x\|^2\cdot \|y\|^2-(x\cdot y)^2=\sum_{1\leq i<j\leq n}(x_i y_j-x_j y_i)^2$$

I am not sure how to derive this equality, because by the definition of inner product, \begin{align*} \|x\|^2\cdot \|y\|^2-(x\cdot y)^2 &= \sum_{1\leq i \leq n}x_i^2 \sum_{1\leq i \leq n}y_i^2 - (\sum_{1\leq i \leq n}x_i y_i)^2 \\ &=\sum_{1\leq i \leq n}x_i^2 y_i^2 + \sum_{1\leq i < j \leq n}(x_i^2 y_j^2+x_j^2 y_i^2) - \left(\sum_{1\leq i \leq n}x_i^2 y_i^2 + 2\sum_{1\leq i < j \leq n}(x_i y_ix_jy_j)\right) \end{align*}

Then I am stuck here and don't know how to cancel out those terms.

Because $$x_i^2y_j^2+x_j^2y_i^2-2x_ix_jy_iy_j=(x_iy_j-x_jy_i)^2$$

Remark

$$\left(\sum_{1\leq i\leq n} a_i\right)^2=\left(\sum_{1\leq i\leq n} a_i\right)\left(\sum_{1\leq j\leq n} a_j\right) =\left(\sum_{1\leq i,j\leq n} a_ia_j\right)=\sum_{1\leq i\leq n} a^2_i+ 2\sum_{1\leq i<j\leq n} a_ia_j$$

$$(x\cdot y)^2 =\left(\sum_{1\leq i\leq n} x_iy_i\right)\left(\sum_{1\leq j\leq n} x_jy_j\right)$$ taking $a_i= x_iy_i$ we get $$(x\cdot y)^2 = \left(\sum_{1\leq i\leq n} x^2_iy^2_i\right)+ 2\sum_{1\leq i<j\leq n} x_ix_jy_iy_j$$

Also we have

$$\|x\|^2\|y\|^2 =\left(\sum_{1\leq i\leq n} x_i^2 \right)\left(\sum_{1\leq i\leq n} y^2_j\right) =\left(\sum_{1\leq i,j\leq n} x^2_iy^2_j\right) \\=\left(\sum_{1\leq i\leq n} x^2_iy^2_i\right)+\left(\sum_{1\leq i\neq j\leq n} x^2_iy^2_j\right)\\=\left(\sum_{1\leq i\leq n} x^2_iy^2_i\right)+\left(\sum_{1\leq i< j\leq n}\color{red}{ x^2_jy^2_i}\right)+\left(\sum_{1\leq i< j\leq n}\color{red}{ x^2_iy^2_j}\right)$$

Carefully see the change of indexes above and take into account that the letters $i,j$ are meaningless

Then

$$\|x\|^2\|y\|^2 -(x\cdot y)^2 = \left(\sum_{1\leq i< j\leq n}\color{red}{ x^2_jy^2_i}\right)+\left(\sum_{1\leq i< j\leq n}\color{red}{ x^2_iy^2_j}\right)- 2\sum_{1\leq i<j\leq n} x_ix_jy_iy_j \\=\sum_{1\leq i< j\leq n}\left(x^2_jy^2_i-2x_ix_jy_iy_j +x^2_iy^2_j\right)\\=\sum_{1\leq i< j\leq n}\left(x_i y_j-x_j y_i\right)^2$$