MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: dummy indices / variables




 Richard Easther wrote:
  ----------
 | ........ coming up with a method to let Mathematica recognize (and
then
 perform
 |simplifications upon) equivalent expressions with dummy indices.
 |
 |For instance,
 |
 |   Sum[f[a],{a,1,m}] + Sum[f[b],{b,1,m}] // FullSimplify
 |
 |does not recognize that the two sums are identical, and misses what
(to
 |a human being, at least!) is a trivial simplification.
 |
Richard,
Sorry if I offended you with my earlier post.

Something like the lines below might solve much of your problem.  I wrap
the  expression with Hold to prevent evaluation of the sums.  Then I
use  InputForm so the result is easy to read via e-mail.

In[1]:=
expr=Hold[Sum[f[a],{a,1,m}] + Sum[f[b],{b,1,m}]+f[a+1]+f[b+1]];


The simple rule in the next line would work for the example you gave. 
After  using Rule (->) to change the dummy variable, I release the
hold.  However,  we run into trouble when (a) is used as a regular
variable and also a dummy  variable as in my example below.

In[2]:=
simple=ReleaseHold[expr/.a->b];
InputForm[simple]

Out[2]//InputForm=
2*f[1 + b] + 2*Sum[f[b], {b, 1, m}]


The code in the next line will work for the example I give, but it only 
changes the dummy variable of a sum of f[_] from 1 to m.  Any other sum
will  not be effected.

In[3]:=
simple=ReleaseHold[expr/.Sum[f[x_],{x_,1,m}]:>Sum[f[a],{a,1,m}]];
InputForm[simple]

Out[3]//InputForm=
f[1 + a] + f[1 + b] + 2*Sum[f[a], {a, 1, m}]


The next line is more versatile.  It will change the dummy variable of a
sum  of any function over any range.

In[4]:=
simple=ReleaseHold[
    expr/.Sum[fun_[x_],{x_,xmin_,xmax_}]:>Sum[fun[a],{a,xmin,xmax}]];
InputForm[simple]
Out[4]//InputForm=
f[1 + a] + f[1 + b] + 2*Sum[f[a], {a, 1, m}]


Similar tricks can probably be used to make more simplifications you
need.

Ted Ersek




  • Prev by Date: RE: Any interest (Wolfram or
  • Next by Date: VirusScan
  • Prev by thread: RE: Any interest (Wolfram or
  • Next by thread: FW: dummy indices / variables