How to do defmatch without using matchdeclare? defmatch(anyname, x(i, l)*x(j, k))$ anyname(x(a,b)*x(c,d)) returns false always
Subject: How to do defmatch without using matchdeclare? defmatch(anyname, x(i, l)*x(j, k))$ anyname(x(a,b)*x(c,d)) returns false always
From: Robert Dodier
Date: Sun, 5 Feb 2006 22:30:25 -0700
Hi Dileep,
>From what you describe here, it sounds like what you
want is defrule and not defmatch.
> Lets say given: x(i, l)*x(j, k) = r(l)s(k)
> I want to replace x(a,b)*x(c,d) in a equation with r(b)s(d) by
> substituting l=b and k=d.
Here's what I get. I'm assuming x is literally the name of
the function in question.
matchdeclare ([a, b, c, d, e], all);
defrule (myrule, x(a,b)*x(c,d)*e, r(b)*s(d)*e);
apply1 (x(i, l)*x(j, k), myrule); => r(k)*s(l)
apply1 (23*x(i+1,j-1)*x(m/2, n/2)/%pi, myrule); => 23*s(j-1)*r(n/2)/%pi
apply1 (sin (x(i,3)*y(i,3)*x(7,j)), myrule); => sin(r(3)*y(i,3)*s(j))
There seems to be ambiguity in the way you've stated the
substitution --- x(a,b)*x(c,d) goes to r(b)s(d),
so x(c,d)*x(a,b) goes to r(d)s(b) -- can we be sure r(d)s(b)
is the same as r(b)s(d) ?
hth
Robert Dodier