Mathematica -difference of two Symbolic summations

  • Context: Mathematica 
  • Thread starter Thread starter Osiris
  • Start date Start date
  • Tags Tags
    Maple Mathematica
Click For Summary

Discussion Overview

The discussion revolves around the manipulation of symbolic summations in Mathematica and Maple, specifically focusing on how to compute differences of sums and the challenges associated with changing the limits of summation variables. Participants explore various approaches and rules for achieving desired results in symbolic computation.

Discussion Character

  • Technical explanation
  • Exploratory
  • Mathematical reasoning

Main Points Raised

  • One participant expresses difficulty in computing the difference between two symbolic summations and expects a specific result that Mathematica does not provide.
  • Another participant suggests that Mathematica and Maple are not effective for abstract manipulations on unevaluated sums and integrals, recommending the use of objects like lists or dummy sum commands for better handling.
  • A participant requests an example of how to apply pattern recognition in Mathematica to achieve the desired summation manipulation.
  • Further, a more general case is proposed, where a participant expects a specific result from manipulating a sum involving constants and a function.
  • A participant provides rules and examples for defining a dummy sum command to avoid evaluation at each step, noting that some rules may be inefficient for complex expressions.
  • Examples are shared that demonstrate the application of the proposed rules to achieve the desired summation results.

Areas of Agreement / Disagreement

Participants generally agree on the limitations of Mathematica and Maple for certain symbolic manipulations, but there is no consensus on the best approach to achieve the desired results, as various methods and rules are proposed without resolution.

Contextual Notes

Some participants note that the rules provided may be slow for expressions with many terms, indicating a potential limitation in efficiency based on the structure of the expressions being manipulated.

Osiris
Messages
19
Reaction score
0
I wish to compute
Sum[f, {i, 0, m}] - Sum[f, {i, 0, j}]

but can't get the expected result
Sum[f, {i, j+1, m}]


I also tried
Sum[f, {i, 0, m}] - f[0]
but can't get the expected result
Sum[f, {i, 1, m}]


It seems that mathematica can't change the minimum/maximum value of the summation variable i above...

I also tried maple, but failed.
 
Physics news on Phys.org
Yep, Mma and Maple aren't very good at abstract manipulations on unevaluated sums and integrals. If you need to do these types of operations on sums/integrals it is best to work with an object (eg a List or a dummy sum command) containing both the summand/integrand and the range/limits, then plug it back into the integral/sum once you are done. Many operations like the one you have above can be automated with pattern recognition.
 
Simon_Tyler said:
Yep, Mma and Maple aren't very good at abstract manipulations on unevaluated sums and integrals. If you need to do these types of operations on sums/integrals it is best to work with an object (eg a List or a dummy sum command) containing both the summand/integrand and the range/limits, then plug it back into the integral/sum once you are done. Many operations like the one you have above can be automated with pattern recognition.

Thanks Simon. I am a newbie of Mathematica and not quite clear about using pattern recognition.

Could you please show an example for an operation above?

How about a more general case:
Sum[a*f, {i, 0, m}] - b*f[0]
I expect to get
Sum[a*f, {i, 1, m}]+(a-b)*f(0)
where a and b are positive integers.
 
Here's a few rules and examples to get you started. I've defined a dummy sum command so that Mma does not try to evaluate the sum at each step.

The last rule is pretty ugly.
i.e. it will be slow in expressions with lots of terms, because it will get tested many times. If you have a more specific structure in mind, then you could make the rules more specific and thus faster.

Code:
In[1]:= sumRules={
sum[expr_,{i_,low_,up1_}]+sum[expr_,{i_,up1_,up2_}]:>sum[expr,{i,low,up2}],
sum[expr_,{i_,low_,up1_}]-sum[expr_,{i_,low_,up2_}]:>sum[expr,{i,up2,up1}],
sum[a_. expr_,{i_,low_,up_}]+b_. expr2_/;(expr2==expr/.i->low):>sum[expr,{i,low+1,up}]+(a+b)expr2};
In[2]:= sumToSum[expr_]:=expr/.sum->Sum

Code:
In[3]:= sum[f[i],{i,0,m}]+sum[f[i],{i,m,j}]/.sumRules
Out[3]= sum[f[i],{i,0,j}]
In[4]:= sum[f[i],{i,0,m}]-sum[f[i],{i,0,j}]/.sumRules
Out[4]= sum[f[i],{i,j,m}]

Code:
In[5]:= sum[7f[i],{i,0,m}]-2f[0]/.sumRules
%/.f[i_]:>i^2+1
%//sumToSum
Out[5]= 5 f[0]+sum[f[i],{i,1,m}]
Out[6]= 5+sum[1+i^2,{i,1,m}]
Out[7]= 5+1/6 (7 m+3 m^2+2 m^3)
 
Last edited:

Similar threads

  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K