matching or some other thing for sums of exponentials?
Subject: matching or some other thing for sums of exponentials?
From: Robert Dodier
Date: Wed, 5 Oct 2011 21:28:45 -0600
I guess I 'm a little late to the pary, but here's something that might work.
matchdeclare ([aa, bb], all);
matchdeclare (xx, "#" (0));
defmatch (eep, bb*%e^xx);
matchdeclare (ee, lambda ([e], eep (e) # false));
defrule (ree, aa + ee, FOO (ee, aa));
FOO (x, y) :=
if op (x) = "+"
then
(eep (first (x)),
y + exp (xx) * expand (x / exp (xx)))
else y + x;
Here are some examples making use of the above:
(%i8) foo : 1 + x + exp(x) + 2*exp(u) - z*y*exp(-w);
(%o8) -%e^-w*y*z+%e^x+x+2*%e^u+1
(%i9) ree (foo);
(%o9) %e^-w*(-y*z+%e^(x+w)+2*%e^(w+u))+x+1
(%i10) apply1 (foo, ree);
(%o10) %e^-w*((2*%e^(u-x)+1)*%e^(x+w)-y*z)+x+1
(%i11) apply1 (sin (foo), ree);
(%o11) -sin(%e^-w*(y*z+(-2*%e^(u-x)-1)*%e^(x+w))-x-1)
(%i12) bar : %pi * exp(%pi*x) - (1/2) * exp(-%pi*x);
(%o12) %pi*%e^(%pi*x)-%e^-(%pi*x)/2
(%i13) apply1 (1 + blurf (bar), ree);
(%o13) blurf((%pi-%e^-(2*%pi*x)/2)*%e^(%pi*x))+1
Hope this helps in some way.
Robert Dodier