# Math Help - Summation Question

1. ## Summation Question

I'm not sure which board this post should be in. If a mod could move it to the appropriate board if this isn't the correct one, that'd be great.

So let A be an array of n integers A[0],...,A[n-1]. where n is a positive number.
If $i = 0$, is $S = \sum^{i-1}_{j=0}A[j] = 0$?

If not, how would you write in summation notation, S is the sum of all the values stored in the array A up to the i'th element, where i < n?

2. Originally Posted by TheMute
So let A be an array of n integers A[0],...,A[n-1]. where n is a positive number.
If $i = 0$, is $S = \sum^{i-1}_{j=0}A[j] = 0$?
Did you make a typo? If $i = 0$, then $i - 1 = -1$ and you have

$\sum_{j=0}^{i-1}A[j] = \sum_{j=0}^{-1}A[j]$

I'm not sure if there is a generally accepted convention when the upper index is less than the lower index. For example, we might interpret this as the empty sum (0), or we might consider this equivalent to

$\sum_{j=-1}^0A[j]$

which would then be undefined since A[-1] is undefined.

Originally Posted by TheMute
If not, how would you write in summation notation, S is the sum of all the values stored in the array A up to the i'th element, where i < n?
You can write $S_i = \sum_{j=0}^iA[j],\ 0\leq i. Here we mean up to and including the i'th element.

In practice, if you're writing a program, you'll generally be using either set notation or a loop with a boolean condition, and it will be clear how to make certain inputs return the empty sum (0), if desired.

3. Originally Posted by undefined
Did you make a typo? If $i = 0$, then $i - 1 = -1$ and you have

$\sum_{j=0}^{i-1}A[j] = \sum_{j=0}^{-1}A[j]$

I'm not sure if there is a generally accepted convention when the upper index is less than the lower index. For example, we might interpret this as the empty sum (0), or we might consider this equivalent to

$\sum_{j=-1}^0A[j]$

which would then be undefined since A[-1] is undefined.
Not a typo. :P

You can write $S_i = \sum_{j=0}^iA[j],\ 0\leq i. Here we mean up to and including the i'th element.

In practice, if you're writing a program, you'll generally be using either set notation or a loop with a boolean condition, and it will be clear how to make certain inputs return the empty sum (0), if desired.
The problem is when I have $i = 0$, I want the summation to equal 0.

This is a me trying to simplify a question I have on a loop invariant problem I have... maybe I should just post that whole problem in the Discrete Mathematics board...

4. Originally Posted by TheMute
Not a typo. :P
Gotcha

Originally Posted by TheMute
The problem is when I have $i = 0$, I want the summation to equal 0.

This is a me trying to simplify a question I have on a loop invariant problem I have... maybe I should just post that whole problem in the Discrete Mathematics board...
In this case I would say your initial formulation is correct, you should just define your terms so that everyone knows exactly what you mean. I haven't seen that notation used in proofs, but my experience is limited and it seems like a reasonable enough use of notation.

So you'll end up having $S_0 = 0$, $S_1 = A[0]$, $S_2 = A[0]+A[1]$, etc., which it seems you're going for.

Whether or not a sum from 0 to -1 is conventionally considered the empty sum, I think you can rest easy because mathematicians make up and adapt notation for their purposes all the time.

Edit: Here's a decent list of some ambiguously defined mathematical terms I got from a Google search, just to illustrate. Like I said, I'm not sure about a universally accepted notation in your case, but at least, it's uncommon enough that Wikipedia seemed not to mention it, etc.

5. Originally Posted by undefined
In this case I would say your initial formulation is correct, you should just define your terms so that everyone knows exactly what you mean. I haven't seen that notation used in proofs, but my experience is limited and it seems like a reasonable enough use of notation.

So you'll end up having $S_0 = 0$, $S_1 = A[0]$, $S_2 = A[0]+A[1]$, etc., which it seems you're going for.

Whether or not a sum from 0 to -1 is conventionally considered the empty sum, I think you can rest easy because mathematicians make up and adapt notation for their purposes all the time.
That's exactly what I'm going for! Ok, thanks.