Defmatch question



The message "v u partitions product" is a warning that
the pattern matcher will try to partition a product, but
actually doesn't exhaustively try  all possible partitions.
It tries essentially ONE.

For example, pat1(sin(x)*cos(t)) should work, but
pat1(x^2*sin(x)*t^2*cos(t))  will fail.

It doesn't actually matter in your example, because you
don't even give it a product.  Pattern matching doesn't
exhaustively try all possible simplifications or transformations
to make an expression match.

You could try defmatch(pat2,exp(u+v))  and that would
work for exp(x+t).
It wouldn't work for exp(x+sin(x)+t+cos(t))  though.

If you really want to collect all the terms that pass some filter, like
freeof(x), then you can write a small loop to do this

if h: x + sin(x)+t +cos(t)
you can look at the main operator  part(h,0) and
depending on that, do something like
p1:[]; p2:[];

for i:1 thru length(h) do  if (r:patx(part(h,i))) then p1:cons(r,p1)
else p2:cons(r,p2);


Of course if part(h,0) is "^" and part(h,1) is a constant like %e,
you would do something else.
The patterns may be used recursively, perhaps.

Good luck.

RJF

Andrei Zorine wrote:
 > Hello there,
 > I've tried the following in Maxima 5.9.0rc3:
 > (C1) matchdeclare(u,freeof(x))$
 > (C2) matchdeclare(v,freeof(t))$
 > (C3) defmatch(pat1, u*v)$
 > v u partitions PRODUCT
 > (C4) pat1(exp(x+t));
 > (D4)                      FALSE
 >
 > I'd expect [u=%E^t, v=%E^x] instead.
 >
 > --
 > A.Z.
 >
 > _______________________________________________
 > Maxima mailing list
 > Maxima@www.math.utexas.edu
 > http://www.math.utexas.edu/mailman/listinfo/maxima