Subject: Help matching variables and their indices
From: Mike Valenzuela
Date: Mon, 25 Feb 2013 14:49:12 -0700
Hello again,
I'm sorry if the community is getting tired of many of my questions, but I
think Maxima could use a tutorial on writing custom rules.
I have tried something similar using the following:
(%i6) matchdeclare([aa,bb,ii,jj],true)$
(%i7) matchdeclare([xx,yy], symbolp)$
(%i8) defrule(sum_power_collapse,
msum(xx[ii],ii,aa,bb)*msum(xx[jj],jj,aa,bb), msum(xx[ii],ii,aa,bb)^2)$
% defmatch: xx[aa] will be matched uniquely since sub-parts would otherwise
be ambigious.
(%i9) apply1( msum(x[i],i,b,c)*msum(x[j],j,b,c), sum_power_collapse);
(%o9) msum(x[i],a,b,c)*msum(x[j],j,b,c)
I had hoped the outcome would have been: msum(x[i],a,b,c)^2. However, you
can see it is not working as I had hoped. I am not sure if I am overlooking
something or a different approach is needed.
Thanks in advance for any advice.