# Square of the sum of n positive numbers

I have a following problem

When we want to write $a^2 + b^2$ in terms of $(a \pm b)^2$ we can do it like that $$a^2 +b^2 = \frac{(a+b)^2}{2} + \frac{(a-b)^2}{2}.$$

Can we do anything similar for $a_1^2 + a_2^2 + \ldots + a_n^2$ ? I can add the assumption that all $a_i$ are positive numbers. I mean to express this as combination of their sums and differences. I know that this question is a little bit naive but I'm curious whether it has an easy answer.

-

Is sunflower's answer enough? – Amr Dec 11 '12 at 15:04

## 2 Answers

Yes. You have to sum over all of the possibilities of $a\pm b\pm c$: $$4(a^2+b^2+c^2)=(a+b+c)^2+(a+b-c)^2+(a-b+c)^2+(a-b-c)^2$$

This can be extended to n factors by:

$$\sum_{k=1}^n a_k^2=\sum_{\alpha=(1,-1,...,-1)\; |a_i|=1}^{(1,...,1)}\frac{\big(\sum_{i=1}^{n}\alpha_ia_i\big)^2}{2^{n-1}}$$

($\alpha$ is a multiindex with values that are either -1 or 1, except the first that is always 1)

-

Another way would be:

$$\frac{\sum_{x\in \{-1,1\}^n}(x_1a_1+x_2a_2+....+x_na_n)^2}{2^n}$$

Where $x_i$ is the ith component of the vector $x$

-

I think this is correct but I still need to check. Unfortunately I have to leave now. I will check it later – Amr Dec 11 '12 at 15:09
nice way to write it too ^.^ I wrote an answer using multiindices... this is probably nicer. But should it not be $2^{n-1}$? – CBenni Dec 11 '12 at 15:12
No. It should be $2^n$ – Amr Dec 11 '12 at 15:19
Try the case when $n=2$ or 1 – Amr Dec 11 '12 at 15:20
nah, sorry. I was looking at the solutions for n=2 or 3 where the first index is 1. (These work just fine too). For those, we have only half the terms and thus, only $2^{n-1}$ but you are correct. – CBenni Dec 11 '12 at 15:26
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 12, "mathjax_display_tex": 4, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.954710841178894, "perplexity_flag": "head"}