MathGroup Archive 2012

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

Search the Archive

Re: Comparing terms of expression with Implied sum over indices

  • To: mathgroup at
  • Subject: [mg126604] Re: Comparing terms of expression with Implied sum over indices
  • From: Christoph Lhotka <christoph.lhotka at>
  • Date: Fri, 25 May 2012 04:53:43 -0400 (EDT)
  • Delivered-to:


it depends on the actual form of your expressions, a possible
way to do it is the following:

Let assume two more complex expressions of the form

expr1=Sum[f[i,j] g[i+j]/(i-j)!,{i,imin},{j,jmin,jmax}];
expr2=Sum[f[l,m] g[l+m]/(l-m)!,{l,lmax},{m,mmin,mmax}];

To check if expr1==expr2 we compare sub-expression by sub-expression:

{{(f[i,j] g[i+j])/(i-j)!,(f[l,m] 

A necessary but not sufficient requirement is that the first element of 
expre12 is equal:

(f[i,j] g[i+j])/(i-j)!==(f[l,m] g[l+m])/(l-m)!

An additional set of conditions must be fulfilled to make con1 true:


Let's  make a set of rules out of con2:


And apply it to con1:


In words: expr1==expr2 under the condition con2. Alternatively you
could use the built in function Simplify together with the assumptions
defined by con2:


Now the question is how to go on from this point.  First, above can be 
merged to a unique function, which returns con2 just and only if it renders
con1 true:


Notice that aux is just valid for a very specific type of expressions
and an additional test has to be made to check that expr1 and expr2
are of the correct "expressional structure" to be compared by aux,
e.g. something like:

aux2[expr1_, expr2_] :=
  Head[expr1] == Head[expr2] && Dimensions[expr1] == Dimensions[expr2]

which should be defined to avoid that aux will compare expressions of
different expressional structure yielding unpredictable results. Maybe
expr1, expr2 can be brought into the same (normal)form so I would
also define a function putting expressions in normal form:

aux3[expr_] := FullSimplify[expr]

Now, I would collect the above to define one unique function, say IfEqual:

IfEqual[expr1_, expr2_] := Module[{nexpr1, nexpr2},
   nexpr1 = aux3[expr1];
   nexpr2 = aux3[expr2];
   If[aux2[nexpr1, nexpr2], aux[nexpr1, nexpr2], nexpr1 == nexpr2]]

which returns the assumptions which need to be made
to evaluate expr1==expr2 to true.

Another story is of course to check if the assumptions returned by IfEqual
are consistent with other calculations...

Hope that helps,


On 05/24/2012 09:33 AM, tom u wrote:
> Does anyone know of a general method to compare terms so that one can simplify expressions with terms that are sums over indices where the the index variables are different?  For example, following expression should symbolically equal 0:
> Sum[f[i],{i,imax}] - Sum[f[j],{j,imax}]
> The terms with sums can be more complicated and also implicit as in the case of tensor notation.  The goal is to have an automatic way to Simplify tensor equations that use different dummy indices.
> Thank you

  • Prev by Date: Re: Question about ColorFunction
  • Next by Date: Re: bubblechart axis scaling
  • Previous by thread: Comparing terms of expression with Implied sum over indices
  • Next by thread: Re: Comparing terms of expression with Implied sum over indices