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 $\displaystyle i = 0$, is $\displaystyle 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 $\displaystyle i = 0$, is $\displaystyle S = \sum^{i-1}_{j=0}A[j] = 0$?
Did you make a typo? If $\displaystyle i = 0$, then $\displaystyle i - 1 = -1$ and you have

$\displaystyle \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

$\displaystyle \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 $\displaystyle S_i = \sum_{j=0}^iA[j],\ 0\leq i<n$. 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 $\displaystyle i = 0$, then $\displaystyle i - 1 = -1$ and you have

$\displaystyle \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

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

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

You can write $\displaystyle S_i = \sum_{j=0}^iA[j],\ 0\leq i<n$. 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 $\displaystyle 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 $\displaystyle 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 $\displaystyle S_0 = 0$, $\displaystyle S_1 = A[0]$, $\displaystyle 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 $\displaystyle S_0 = 0$, $\displaystyle S_1 = A[0]$, $\displaystyle 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.