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?
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?
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.
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)$
{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
{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
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
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$.
$$blah.$$
to prevent the orphaned period.
– Arturo Magidin
Apr 25 '11 at 21:16
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 sum $\sum_{i=a}^b{f(i)}$, where $a$ and $b$ are integers, can be defined using any two of:
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:
Integration has analgous properties and definitions. For example:
[Note that some of these formulas would be cleaner if the upper index were exclusive, but unfortunately it is inclusive.]
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.