20

How does one evaluate something like the following? $$\sum_{k=0}^{-1}\left( 5\times 2^k \right)$$

When I type this into Mathematica it returns 0. Can someone explain why this is?

4 Answers4

43

The sum $$\sum_{k=a}^b f(k)$$ for integers $a$ and $b$ is usually (often, but not exclusively) interpreted as the sum of all values of $f(k)$ for $k$ an integer, $a\leq k\leq b$.

If $a\gt b$, then there are no integers $k$ that satisfy the condition $a\leq k\leq b$, so this is a sum with no summands (or "empty sum").

In order to make sure that associativity laws are respected, empty sums (sums with no summands) are defined to be equal to $0$ (likewise, empty products are defined to be equal to $1$).

Since your sum is empty, it is equal to zero by definition.

See also: this question (discussing the value of a "product with no factors"); the same argument for why the product with no factors "should" be equal to $1$ applies to see why the sum with no summands "should" be equal to $0$, based on associativity.

Arturo Magidin
  • 398,050
  • 1
    This is neither the interpretation of Mathematica nor is it the only useful mathematical interpretation, see my response. – Phira Apr 25 '11 at 21:25
  • 1
    @user9325: If there is something in my response that is false, I'll be happy to correct it. If your whole point is "this is not as good as my answer", then perhaps your comment should be addressed at the OP. – Arturo Magidin Apr 25 '11 at 21:28
  • @Arturo Magidin You say that "the sum is interpreted as" which is not correct in the context of this question or in all mathematical contexts. I think that it is useful to leave a comment under an accepted answer that does not answer the posed question. You will note that I did not ask you to do anything and you are certainly free to think that mathematica uses your convention. – Phira Apr 25 '11 at 21:34
  • 4
    @user9325: I do not "think that Mathematica uses [my] convention" (nor is it my convention; it is a very generally accepted convention). I did not know what Mathematica uses, and voted up your answer for the information. The question does not ask why Mathematica evaluates it to zero (or even how Mathematica evaluates the sum), but rather "how does one" evaluate the sum (the comment about Mathematica follows the question). As such, I disagree that the reply "does not answer the posed question"; the posed question is "how does one evaluate a sum with upper limit smaller than lower limit?" – Arturo Magidin Apr 25 '11 at 21:38
  • @9325: FWIW, a for-loop where the starting value is greater than the ending value, and the increment is positive, in most languages nowadays does not execute. This is consistent with defining empty sums to be 0 and empty products to be 1. – J. M. ain't a mathematician Apr 26 '11 at 00:38
  • For the record, please note that my first comment here was in response to the formulation that "the sum is interpreted as" followed by the definition given, the qualifiers were edited in later. The response was that my comment should go away. This issue has nothing to do with empty sums being $0$. – Phira Apr 26 '11 at 06:19
  • 1
    @user9325: For the record, the response was not that "the comment should go away", it was that perhaps it should be adressed elsewhere. For the record, your claim that I did not "answer the posed question" continues to ignore what the initial question of the post is. For the record, your written explanation as it now stands of Mathematica's treatment of the sum completely ignores the question of what happens when upper limits are larger than lower limits, and your recasting of it with a counter increment of -1 is not the default parsing, according to others. – Arturo Magidin Apr 26 '11 at 13:16
  • I did not "recast" anything with a counter increment of $-1$, I just indicated how to write an expression that gives the result that was claimed to be the answer of the question in a now-deleted comment (which was among the first reactions to the OP). And I state that all interpretations give $0$. – Phira Apr 26 '11 at 19:39
  • 2
    @user9325: Then perhaps you can clarify that sentence, given that there is no "the comment" to refer to any more, while you spend some time explaining what Mathematica does when the upper limit is smaller than the lower limit (saying it treats it as an explicit sum as you do does not answer the first question asked by the OP, which is how to evaluate a sum of terms where the first term has larger argument than the last term). You know, geese and gander and all that. Or don't. I do begin to understand, though, some of your comments in meta. – Arturo Magidin Apr 26 '11 at 20:19
8

Mathematica treats a sum $\sum_{k=a}^{b}f(k)$ as the sum $f(a)+f(a+1)+\cdots + f(a+\lfloor{b-a}\rfloor)$ which is one possible interpretation that allows sums with non-integer arguments. You can write Sum[f[k],{k,0,-1,-1}] to get the result of the comment.

Another common interpretation is that this sum runs over all integers between $a$ and $b$.

Another common and useful interpretation is the one that for integers $a,b,c$ respects $$\sum_{k=a}^{b-1}f(k) +\sum_{k=b}^{c-1}f(k) =\sum_{k=a}^{c-1}f(k).$$

This interpretation has the big advantage that many summation formulas hold for positive and negative upper summation index simultaneously.

For your sum, all common interpretations give $0$ even though the last interpretation gives $\sum_{k=0}^{-2}f(k) = -f(-1)$

Arturo Magidin
  • 398,050
Phira
  • 20,860
  • 2
    +1 for the interpretation that preserves additivity of sums. Two things worth mentioning in that respect: a) This only makes sense for invertible addition operations. b) There's a direct analogy with integrals, where this is in fact the only accepted interpretation of reversing the limits. The fact that we need awkward $-1$s in case of the sums is also just a matter of convention; the formula would correspond even more closely to the additivity of integrals if we'd define sums so as to exclude one of the limits. – joriki Apr 25 '11 at 21:33
  • @Arturo Magidin Thanks for the tex clean-up. – Phira Apr 25 '11 at 21:37
  • If you're going to go that route, you have to find a way to somehow indicate that the increment for the dummy variable is negative. The iterator {k,0,-1,-1} is valid in Mathematica since you keep adding increments of -1 to k==0 until you reach the value k==-1; if you had, say, {k,0,-1} (implicitly, {k,0,-1,1}), then Arturo's answer applies. – J. M. ain't a mathematician Apr 26 '11 at 00:43
  • @user9325: Could you clarify something in your first sentence? I don't understand what happens if $b-a\lt 0$; does Mathematica automatically perform a negative increment, or does it parse the sum as empty? If this is implemented as either a while-loop or a for-loop where the index is initialized to $i=a$, the sum to $0$, and at each step we add $f(i)$ to the running total and increment $i$ until the index exceeds $a+\lfloor b-a\rfloor$, then the sum would be empty and give a result of $0$. But if Mathematica adds all integer values "between" $a$ and $a+\lfloor b-a\rfloor$, it's different. – Arturo Magidin Apr 26 '11 at 02:36
  • @Arturo: The default increment Mathematica uses for an iterator like {i, 0, 10} is 1 (i.e., this is explicitly the same as {i, 0, 10, 1}). Thus, if the starting index is greater than the ending index and there is no explicitly given increment (e.g. {i, 3, 2}), Sum[] will return 0, Product[] will return 1, Table[] will return an empty list {} and Do[] will not execute its body, to use some examples of Mathematica entities that use iterators. – J. M. ain't a mathematician Apr 26 '11 at 03:07
  • @J.M. Thanks! So it behaves like a while-loop with default increment, leading to an empty sum in those situations, hence the answer "0" the OP is getting. – Arturo Magidin Apr 26 '11 at 03:09
  • @Arturo: Yeah, that's why 9325's "not the interpretation of Mathematica" puzzles. It would be rather peculiar if it were done differently... – J. M. ain't a mathematician Apr 26 '11 at 03:11
  • @J.M Sum[f[k],{k,1/2,2}] gives f[1/2]+f[3/2], not f[1]+f[2] which I indicated with "allows non-integer arguments". And yes, the sum as I wrote it is indeed empty for $b< a$. – Phira Apr 26 '11 at 06:06
  • @9325: For noninteger indices and positive increment, one keeps adding the increment as long as the "running total" is less than the ending index, so yeah... (in the case you gave, keep adding 1 to 1/2 as long as the running total's less than 2.) – J. M. ain't a mathematician Apr 26 '11 at 12:07
3

I think it is a convention that summations start at the lower limit and increment by $1$ until the upper bound is reached. In your example there is no allowable value for $k$ that is no larger than the upper bound. You are adding together an empty collection of elements. Suppose that $A$ is a set of numbers. Consider

$$N = \sum A$$ and

$$ \sum (A \cup \varnothing) = \sum A + \sum \varnothing.$$

Since $A = A \cup \varnothing$ the two sums should be equal. But then $\sum \varnothing = 0$.

Jay
  • 3,822
1

This answer will argue for the definition in the "another common and useful interpretation" by Phira, and against what Arturo states - probably correctly - is the most common definition.

The possible definitions agree that $\sum_{i=a}^{a-1}{f(i)} = 0$, but disagree on $\sum_{i=a}^{b}{f(i)}$ when $b < a - 1$.

The rule-obeying definition

The sum $\sum_{i=a}^b{f(i)}$, where $a$ and $b$ are integers, can be defined using any two of:

  1. Base case [note the sum from a to a could be used instead] $$\sum_{i=a}^{a-1}{f(i)}=0$$
  2. Finite differences $$\sum_{i=a}^{b+1}{f(i)} - \sum_{i=a}^{b}{f(i)} = f(b+1)$$
  3. Associativity $$\sum_{i=a}^{b}{f(i)} + \sum_{i=b+1}^{c}{f(i)} = \sum_{i=a}^{c}{f(i)}$$

According to this definition, $\sum_{i=0}^{-2}{f(i)} + f(-1) = \sum_{i=0}^{-1}{f(i)} = 0$ from finite differences and base case, so $\sum_{i=0}^{-2}{f(i)} = - f(-1)$ as Phira notes.

Equivalent definitions include:

  • To find $\sum_{i=a}^{b}f(i)$: Let $\mu(x)$ for $x>c$ be the measure which puts mass $1$ on each integer up to $x$, and take the signed measure $\mu'=\mu(b)-\mu(a-1)$. Then $\sum_{i=a}^{b}{f(i)}=\int f(i) \,\mathrm{d}\mu'(i)$.
  • $\sum_{i=a}^{b}f(i)$ equals $\sum_{i\in\{i:a\le i\le b\}}f(i)$ when $a \le b-1$, and $-\sum_{i\in\{i:b+1\le i\le a-1\}}f(i)$ otherwise.

Integration has analgous properties and definitions. For example:

  • $\int_{i=a}^{b}f(i)$ equals $\int 1_{[a,b]}(x)f(x) \,\mathrm{d}x$ when $a \le b$, and $\int_{i=a}^{b}f(i)$ equals $-\int 1_{[b,a]}(x)f(x) \,\mathrm{d}x$ otherwise.

[Note that some of these formulas would be cleaner if the upper index were exclusive, but unfortunately it is inclusive.]

The simple set definition

An alternative definition is: $$\sum_{i=a}^{b}f(i) = \sum_{i\in\{i:a\le i\le b\}}f(i)$$

This definition gives $\sum_{i=0}^{-2}{f(i)} = 0$. It is the one that Wolfram uses when restricted to integers. It has the advantage that is short to write down and the outputs are more often $0$, which is also short to write down. However, it does not satisfy finite differences or associativity, and as a result many other formulas break down, for example the well-known formulas for sums of powers of $i$, arithmetic series, and geometric series. It also loses the analogy to integration.