Re: problem with Sum
- To: mathgroup at smc.vnet.net
- Subject: [mg100684] Re: problem with Sum
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Thu, 11 Jun 2009 07:06:59 -0400 (EDT)
On 6/10/09 at 5:31 AM, olfa.mraihi at yahoo.fr (olfa) wrote: >I have this input: Sum[a[k], {k, 1, j}] - Sum[a[k], {k, 1, i+j-n}] >How it is possible to let mathematica gives as output: Sum[a[k], {k, >i+j-n+1, j}] if i+j-n<j and Sum[a[k], {k, j+1, i+j-n}] if i+j-n>j Have you looked at the documentation for If? Specifically, If[i<n, Sum[a[k], {k, 1, i+j-n}], Sum[a[k], {k, j+1, i+j-n}]] here, I've simplified your i+j-n < j to the equivalent i < n. Or perhaps you are asking how to transform Sum[a[k], {k, 1, j}] - Sum[a[k], {k, 1, i+j-n}] to say Sum[a[k], {k, 1, i+j-n}] That can be done using pattern matching with a replacement rule. That is: In[9]:= x = Sum[a[k], {k, 1, j}] - Sum[a[k], {k, 1, i + j - n}] Out[9]= Sum[a[k], {k, 1, j}] - Sum[a[k], {k, 1, i + j - n}] In[10]:= First[x] /. j -> i + j - n Out[10]= Sum[a[k], {k, 1, i + j - n}]