On 2/13/07, Ryan Krauss <ryanlists at gmail.com> wrote:
>
> How would I make a rule or set a flag to tell Maxima that I would
> prefer to have expression of this form:
> (%e^(a*T)-1)/(z*%e^(a*T)-1)
> changed to this:
> (1-%e^(-a*T))/(z-%e^(-a*T))
Try
negexpsimp(ex) := subst(1/%e,%e, factor( subst( 1/%e,%e, ex )))
negexpsimp( (%e^(a*T)-1)/(z*%e^(a*T)-1), T )
This takes advantage of the fact that factor (like rat, ratsimp, etc.)
prefers positive exponents, so it uses factor on negated exponents, then
substitutes back the negative exponents. Instead of "factor", you can also
try "rat", "ratsimp", etc.
I don't think it would be easy or a good idea to make this happen
automagically (e.g. as a post-simplification on every displayed expression),
though, partly because it is not always valid (see below), partly because it
isn't always helpful, e.g.
(%e^x-%e^-y)/(%e^y+%e^x)
=> -(%e^(-y-x)-1)*%e^-y/(%e^-y+%e^-x)
and partly because it would be clumsy to set up.
negexpsimp is NOT always valid -- for example, float(negexpsimp( log(%e+1)
)), logexpand:all => -0.69, while float(log(%e+1)) => 1.31. But I believe
it is valid in the absence of logs, exponentialize:true, etc. If you are
worried about those cases, then instead try
negexpsimpv(ex,var) := subst(-var,var, factor( subst( -var,var, ex
)))
negexpsimpv( (%e^(a*T)-1)/(z*%e^(a*T)-1), T )
but of course this requires identifying the relevant variable, and probably
doesn't do what you expect in, e.g.
negexpsimpv( negexpsimpv( (%e^x-%e^y)/(%e^y+%e^x) , x) , y)
=> (%e^(x-y)-1)/(%e^(x-y)+1)
but
negexpsimp( (%e^x-%e^y)/(%e^y+%e^x) )
=> (%e^-y-%e^-x)/(%e^-y+%e^-x)
-s