matching or some other thing for sums of exponentials?
Subject: matching or some other thing for sums of exponentials?
From: dlakelan
Date: Mon, 03 Oct 2011 17:13:26 -0700
I have an expression that I get back from ode2 which contains things
like (a*%e^b + %e^c)
I would like to convert this to %e^c*(a*%e^(b-c)+1) or maybe in general
take the sum of two exponentials multiplied by something and do this:
a*exp(b) + c*exp(d) -> exp(d) * (a*(exp(b)/exp(d)) + c)
one of the reasons I want to do this is that many times this appears
inside a logarithm and the resulting simplifications will eliminate
intermediate overflows in floating point.
I can't figure out how to do this with matching / defrule, or with
fooling around using factor or factorsum or anything like that.
One of the problems seems to be the general problem that matching sub
parts of sums or products can be tricky.
any ideas?