matching or some other thing for sums of exponentials?



Well, here's what I did (for those reading the archive):

Since my problem is specific to this expression I didn't go for a
general purpose solution, instead what I did was match any sum that
contains %e in every term and then simply pull out the first term using
multthru to distribute the multiplication.


matchdeclare(sumofexps,lambda([x],not(atom(x)) and op(x) = "+" and
every(lambda([x],not(freeof(%e,x))),args(x))));

pulloutfirstexp(sumofx) :=
part(sumofx,1)*(multthru(1/part(sumofx,1),sumofx));

defrule(sumexp,sumofexps,pulloutfirstexp(sumofexps));

Applying this rule using apply1, together with starting my mnewton
session at a better initial condition fixed my intermediate floating
point overflow problems and I got the numerical answer I was looking for.