how to do this substitution? Plz suggest



Again, I think what you are trying to do is already available.
See
http://arxiv.org/PS_cache/cs/pdf/0503/0503073.pdf

Generally, the use of macsyma's top-level pattern matcher
(defrule, defmatch, tellsimp,...)
is plausible for defining rules for newly-defined functions,
and for picking out coefficients in a sum or product, e.g.
the coefficient of x^2.

It is not suitable for backtrack matching in which the intention
is to find, after some number of attempts, a way of matching
terms in a sum or product by some unguided heuristic.

If you want to write a program that looks at the summation
index, here i1,  and then looks for repeated occurrences of
i1 in the summand, and then constructs a new summand, then
you can go write such a program.  In your pattern indicated
below, you are looking for a product of EXACTLY TWO
items in the sum,  d(i,j), f(i),   where i= index of summation.

The pattern will NOT match any product of 3 or more terms.

Do NOT write a pattern with 3 terms:  they will be either matched
or not in ONE PASS.  If a different permutation of the terms 
could match, the matching program WILL NOT look for it.

How to fix this? grab the summand.  (You can do this with
pattern matching if you wish. )  Put each of the terms in
a list.  Then iterate over the list looking for what you want.

Or, use someone else's program.
Good luck.
RJF


----- Original Message ----- 
From: <dp2 at cise.ufl.edu>
To: <Maxima at math.utexas.edu>
Sent: Saturday, February 11, 2006 2:14 PM
Subject: how to do this substitution? Plz suggest


> Hi,
> I need to apply a substitution rule in the following manner:
> Lets say
> 
> (%i14) eq:sum(d(i1,i2)*f(i1)*d(i3,i1),i1,1,n);
> 
>                                    n
> 
>                               ====
> 
>                               \
> 
> (%o14)                      >     f(i1) d(i1, i2) d(i3, i1)
> 
>                               /
> 
>                               ====
> 
>                               i1 = 1
> 
> 
> 
> Now, I need to substitute it with
>            f(i2)*d(i3,i2)
> i.e. I am removing summation and function "d(index of the summation, any
> variable say i2)", as well as replacing index of summation in all the
> functions within the summation with the i2 (the second variable of
> function d).
> 
> I tried the following thing but didn't work.
> 
> (%i10) matchdeclare([i,j,k,q],all);
> 
> (%o10)                                           done
> 
> (%i12)   apply(defrule,[rule1,sum(d(i,j)*q(i),i,1,k),q(j)]);
> 
> 
> 
>                                           k
> 
>                                          ====
> 
>                                          \
> 
> (%o12)                    rule1 :  >    q(i) d(i, j) -> q(j)
> 
>                                          /
> 
>                                          ====
> 
>                                          i = 1
> 
> (%i13) apply(apply1,[eq,rule1]);
> 
>                                    n
> 
>                               ====
> 
>                               \
> 
> (%o13)                      >     d(i1, i2) f(i2) d(i3, i2)
> 
>                               /
> 
>                               ====
> 
>                               i2 = 1
> 
> 
> Although I was able to do it with one specific function, like this:
> 
> (%i16)   apply(defrule,[rule1,sum(d(i,j)*f(i),i,1,k),f(j)]);
> 
> 
> 
>                                           k
> 
>                                          ====
> 
>                                          \
> 
> (%o16)                    rule1 :  >    f(i) d(i, j) -> f(j)
> 
>                                          /
> 
>                                          ====
> 
>                                          i = 1
> 
> (%i17) eq:sum(d(i1,i2)*f(i1),i1,1,n);
> 
>                                         n
> 
>                                        ====
> 
>                                        \
> 
> (%o17)                               >        f(i1) d(i1, i2)
> 
>                                        /
> 
>                                        ====
> 
>                                        i1 = 1
> 
> (%i18) apply(apply1,[eq,rule1]);
> 
> (%o18)                                           f(i2)
> 
> 
> 
> But, the equation within summation can have more functions in product.
> 
> If you have any clue, please suggest.
> Regards
> 
> Dileep
> 
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>