26

What is difference between square of sum $(\sum_{i=1}^{n}x_i)^2$ and sum of square $\sum_{i=1}^{n}x_i^2$?

I think square of sum is bigger than sum of square but i can not find a relation between them.

I mean:

$$\left(\sum_{i=1}^{n}x_i\right)^2=\sum_{i=1}^{n}x_i^2+?$$

achmed
  • 261
  • 2
    The mean of the square is greater than or equal to the square of the mean, from Jensen's inequality. – Bill Kleinhans Jul 08 '13 at 22:02
  • 2
    Welcome to MSE. Please note that in standard English orthography, the first person singular subject pronoun, "I", is always capitalized. – dfeuer Jul 08 '13 at 22:40

4 Answers4

43

If $x_i\ge 0$, then $$\left(\sum_{i=1}^n x_i\right)^2=\sum_{i=1}^n \sum_{j=1}^n x_i x_j=\sum^{n}_{i=1}x_i^2+\sum^n_{i=1}\sum_{j=1,j\not=i}^n x_i x_j\ge \sum_{i=1}^n x_i^2$$ On the other hand, by the Cauchy-Schwarz inequality, $$\left(\sum_{i=1}^n x_i\right)^2=\left(\sum_{i=1}^n 1\cdot x_i\right)^2\le n\cdot\sum_{i=1}^{n} x_i^2$$ So if $n$ is fixed, the sum of squares and the square of the sum are equivalent quantities, i.e. can be estimated against eachother loosing only a multiplicative constant.

Anonymous999
  • 1,298
  • Can you elaborate on that last sentence? How do you show there is only a multiplicative constant between sum of squares and square of sums, when there is no lower bound on the square of sums (other than zero)? – Sideshow Bob Jan 27 '15 at 19:21
  • The lower bound is the first line. @Sideshow Bob – Anonymous999 Mar 11 '15 at 10:52
  • @Anonymous999 You meant assuming $x_i$'s are non-negative? (I have the same question as @SideshowBob.) – shall.i.am Sep 16 '15 at 05:10
  • @SideshowBob From the answer we know $\sum x_i^2\leq(\sum x_i)^2\leq N\sum(x_i)^2$, then when $N$ is fixed, the two quantities has the same order. – chloe May 30 '23 at 11:06
16

Quite literally the difference is captured by a special case of Cauchy's formula, $$ n \sum_{i = 1}^{n} x_i^2 - \bigg ( \sum_{i = 1}^{n} x_i \bigg)^2 = \tfrac 12 \sum_{i = 1}^{n} \sum_{j = 1}^{n} (x_i - x_j)^2 $$ Note that Cauchy-Schwarz is a consequence. The general case is available here: https://en.wikipedia.org/wiki/Cauchy%E2%80%93Schwarz_inequality#Rn_(n-dimensional_Euclidean_space)

blabler
  • 1,880
  • How does this help with the OP? Your first term has an $n$ in front of it, while the OP is asking about $\sum_i x_i^2$ vs $(\sum_i x_i)^2$. Thank you – Confounded Aug 25 '21 at 18:47
  • Also, what type of Cauchy formula is that? Does it have a name? Where does it come from? Thank you – Confounded Aug 25 '21 at 19:46
  • @blabler indeed, I cannot find this Cauchy's formula. Do you have a reference? – CuriousGuy Jan 18 '23 at 14:42
  • In the right half, the $\frac{1}{2}$ can be omitted if you initialize $j$ to $i+1$ instead of $1$. Reduces the number of iterations as well, in case someone programs it. – Frost Apr 24 '23 at 10:34
  • Could you provide an intuitive/graphical explain of this inequality? – chloe May 30 '23 at 11:08
2

In general, you have

$$\bigg(\sum_i x_i\bigg)^2 = \sum_i \sum_j x_i x_j = \sum_i x_i^2 + \sum_i \sum_{j \neq i} x_i x_j$$

However, this does not allow to tell which one of the two is greater.

-3

Additionally, while the derivation is lengthy to show, the difference when summing over the naturals can be explicitly expressed as a polynomial, quite surprisingly

$(\sum_{i=1}^{n}i)^2-\sum_{i=1}^{n}(i^2)=\frac{n}{12}(n^2-1)(3n+2), n\in\mathbb{N}$