Write sums of combinations of signed sums

combinationscombinatoricssummation

I am looking for a short way to write sums of combinations of $x_1,x_2,\ldots,x_n$ for a practical application. It can be easier explained using an example:

For $n=3$ there are $2^3=8$ combinations to sum $x_1,x_2,x_3$ using all signed combinations: $$C_3=-f\left(-x_1-x_2-x_3\right)+f\left(x_1-x_2-x_3\right)+f\left(-x_1+x_2-x_3\right)-f\left(x_1+x_2-x_3\right)+f\left(-x_1-x_2+x_3\right)-f\left(x_1-x_2+x_3\right)-f\left(-x_1+x_2+x_3\right)+f\left(x_1+x_2+x_3\right)$$
Every combination are summed arguments of a function $f$ and has a different sign sequence. The signs of $f$ are negative/positive if the number of negative signs in the arguments are odd/even.

For $n=4$ there are already $2^4=16$ combinations and it is quite ineffective to write them all down:
$$C_4=f\left(-x_1-x_2-x_3-x_4\right)-f\left(x_1-x_2-x_3-x_4\right)-f\left(-x_1+x_2-x_3-x_4\right)+f\left(x_1+x_2-x_3-x_4\right)-f\left(-x_1-x_2+x_3-x_4\right)+f\left(x_1-x_2+x_3-x_4\right)+f\left(-x_1+x_2+x_3-x_4\right)-f\left(x_1+x_2+x_3-x_4\right)-f\left(-x_1-x_2-x_3+x_4\right)+f\left(x_1-x_2-x_3+x_4\right)+f\left(-x_1+x_2-x_3+x_4\right)-f\left(x_1+x_2-x_3+x_4\right)+f\left(-x_1-x_2+x_3+x_4\right)-f\left(x_1-x_2+x_3+x_4\right)-f\left(-x_1+x_2+x_3+x_4\right)+f\left(x_1+x_2+x_3+x_4\right)$$

It is clear that for higher $n$ a short notation is needed. I do not look for a program code.

Best Answer

We can write $C_n$, for every non-negative integer $n$, as $$C_n = \sum_{(s_1, s_2, \dots, s_n) \in \{-1, 1\}^n}s_1s_2\cdots s_n \cdot f\Big(s_1x_1 + s_2x_2 + \dots + s_nx_n\Big),$$ where $\{-1, 1\}^n := \Big\{(s_1, s_2, \dots, s_n) \mid s_i \in \{-1, 1\} \text{ for all positive integers } i \leq n\Big\}$.

The idea is to just use the "variables" $s_i$ to act as the signs.

For example, $\{-1, 1\}^3$ is defined to be $$\{(\color{red}{-1}, \color{red}{-1}, \color{red}{-1}), (\color{red}{-1}, \color{red}{-1}, \color{green}{+1}), (\color{red}{-1}, \color{green}{+1}, \color{red}{-1}), (\color{red}{-1}, \color{green}{+1}, \color{green}{+1}), (\color{green}{+1}, \color{red}{-1}, \color{red}{-1}), (\color{green}{+1}, \color{red}{-1}, \color{green}{+1}), (\color{green}{+1}, \color{green}{+1}, \color{red}{-1}), (\color{green}{+1}, \color{green}{+1}, \color{green}{+1})\},$$ so we have \begin{align*} C_3 = & \: (\color{red}{-1})(\color{red}{-1})(\color{red}{-1}) \cdot f\Big((\color{red}{-1})x_1 + (\color{red}{-1})x_2 + (\color{red}{-1})x_3\Big) \:+ \\ & \: (\color{red}{-1})(\color{red}{-1})(\color{green}{+1}) \cdot f\Big((\color{red}{-1})x_1 + (\color{red}{-1})x_2 + (\color{green}{+1})x_3\Big) \:+ \\ & \: (\color{red}{-1})(\color{green}{+1})(\color{red}{-1}) \cdot f\Big((\color{red}{-1})x_1 + (\color{green}{+1})x_2 + (\color{red}{-1})x_3\Big) \:+ \\ & \: (\color{red}{-1})(\color{green}{+1})(\color{green}{+1}) \cdot f\Big((\color{red}{-1})x_1 + (\color{green}{+1})x_2 + (\color{green}{+1})x_3\Big) \:+ \\ & \: (\color{green}{+1})(\color{red}{-1})(\color{red}{-1}) \cdot f\Big((\color{green}{+1})x_1 + (\color{red}{-1})x_2 + (\color{red}{-1})x_3\Big) \:+ \\ & \: (\color{green}{+1})(\color{red}{-1})(\color{green}{+1}) \cdot f\Big((\color{green}{+1})x_1 + (\color{red}{-1})x_2 + (\color{green}{+1})x_3\Big) \:+ \\ & \: (\color{green}{+1})(\color{green}{+1})(\color{red}{-1}) \cdot f\Big((\color{green}{+1})x_1 + (\color{green}{+1})x_2 + (\color{red}{-1})x_3\Big) \:+ \\ & \: (\color{green}{+1})(\color{green}{+1})(\color{green}{+1}) \cdot f\Big((\color{green}{+1})x_1 + (\color{green}{+1})x_2 + (\color{green}{+1})x_3\Big). \end{align*}

Related Question