0

Let's say I want to write the following sum in a more compact way

$$a=z_1+z_2+\dots +z_{n/2}-z_{n/2+1}-z_{n/2+2}-\dots -z_{n}$$

Is there some kind of syntax to write that in a more compact way... Something like $$a=\sum _i ^{n}z_i$$ but with some operator that would change sign from + to - at $i=n/2$ ?

skrat
  • 77
  • $\sum\limits_i^{n/2}(z_i-z_{n/2+i})$ is pretty ugly but it's a way to write it as a single summation, splitting it into $2$ summations is probably better – Alessandro Codenotti Mar 28 '16 at 13:19

3 Answers3

3

The clearest would in my opinion be $$ a = \sum_{i=1}^{n/2} z_i - \sum_{i=n/2+1}^n z_i $$

But if you insist on using only one summation sign, you can employ the Iverson bracket: $$ a = \sum_{i=1}^n (-1)^{[i>n/2]}z_i $$

This is not quite so standard notation that you can expect random readers to understand it without you explaining it before you use it, though.

You can also use something like the signum function $$ a = \sum_{i=1}^n \operatorname{sgn}(\tfrac n2+\tfrac12-i)z_i $$ though that gets closer to the realm of obfuscation in my opinion.

  • Could you expand your answer for the following case: Let's say I want add the terms $z_i$ for for all $i$ smaller than $k$ and subtract all the terms where $i$ is greater than $k$. Example: let $k$ be 2. Than $a_1=z_1$ and $a_2=z_1+z_2$ now $i$ becomes greater than $k$ therefore $a_3=z_1+z_2-z_3$ and finally $a_4=z_1+z_2-z_3-z_4$. – skrat Mar 28 '16 at 13:39
  • 1
    @skrat: Just say $k$ whenever I have $n/2$. in the answer. – hmakholm left over Monica Mar 28 '16 at 13:42
2

What about the formula $a=\sum_{i=1}^n (-1)^{\lfloor \frac{2i-1}{n}\rfloor}z_i$ ?

Here $\lfloor *\rfloor$ denotes the floor function, and note that $\lfloor \frac{2i-1}{n}\rfloor$ is equal to $0$ for $i=1,2,\ldots,n/2$, and it is equal to $1$ for $i=n/2+1,\ldots,n$.

Darío G
  • 4,878
0

$$\sum \limits_{i = 1}^n z_i \cdot (1 - 2 I\{2i > n\})$$

Dominik
  • 19,963