Re: maximum of a series
- To: mathgroup at smc.vnet.net
 - Subject: [mg114144] Re: maximum of a series
 - From: Bill Rowe <readnews at sbcglobal.net>
 - Date: Thu, 25 Nov 2010 05:56:52 -0500 (EST)
 
On 11/24/10 at 7:00 AM, olfa.mraihi at yahoo.fr (olfa) wrote:
>On 20 nov, 12:10, Bill Rowe <readn... at sbcglobal.net> wrote:
>>On 11/19/10 at 5:08 AM, olfa.mra... at yahoo.fr (olfa) wrote:
>>>how can I represent for example themaximumof the summations
>>>:sum[a[k],{k,i,j}] where j varies from i to n?
>>I will take your "represent" as "determine". That is I take your
>>question to be how to find themaximumof the partial sums that are
>>(in principle) formed when evaluating
>>Sum[a[k],{k,i,j}]
>>If I have this correct, I suggest
>>Max@Accumulate@Table[a[k], {k,i,j}]
>>Evaluation of Sum only returns the final sum not any of the
>>intermediate sums (which Mathematica may not actually compute).
>>I've used Table to create each of the a[k] terms and Accumulate to
>>compute the partial sums.
>what I need exactly is to solve this system for m using reduce,
>Max[m, s + Max[Table[Sum[a[index2], {index2, i, index1}], {index1,
>i, N}]]] ==
>Max[m, t + Max[Table[Sum[a[index2], {index2, j, index1}], {index1,
>j, N}]]]
>but I have the error: iterator in Table does not have appropriate
>bounds
You cannot use N as the maximum value for Table. N has built in
meaning and cannot be used as a symbol taking a numeric value.
Try replacing N with a lower case n and see if this fixes the
problem. You would be well advised to never use an uppercase
letters as a variable name. Even better, don't have any
variable/symbol/function you create start with an uppercase
letter. This will ensure conflicts with built in objects cannot
occur since the names of all built-in objects start with an
uppercase letter.
Additionally, your code is inefficient. It repeatedly computes
partial sums. With valid values for index1 and the upper limit
n, your code
Table[Sum[a[index2], {index2, i, index1}], {index1, i, n}]
can be replaced with
Accumulate@Table[a[index2], {index2, i, n}]
or even better if a is a function with the attribute listable
Accumulate[a[Range[i,n]]
Here, I make the assumption a[n] is what Mathematica interprets
it to be, i.e., the function a evaluated at n.