Re: Hold and Simplify
- To: mathgroup at smc.vnet.net
- Subject: [mg77237] Re: [mg77143] Hold and Simplify
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Wed, 6 Jun 2007 06:49:25 -0400 (EDT)
- References: <200706051025.GAA00506@smc.vnet.net>
On 5 Jun 2007, at 19:25, news.inode.at wrote: > > > Hi, > > > > I would like to change Exponential functions of sums to products of > > exponential functions. From reading postings from the year 2004 I > tried > > the following: > > > > f[Exp[x_ + y_]] := Exp[x + y] /. Exp[a_ + b_] :> HoldForm[Exp[x]*Exp > [y]]; > > > > Simplify[Exp[a + b], TransformationFunctions -> f] > > > > Unfortunately this gave me > > Exp[a+b] The output you want to get has a high LeafCount so you need to change your ComplexityFunction as well. f[expr_] := expr /. Exp[(a_) + (b_)] :> HoldForm[Exp[a]*Exp[a]]; Simplify[Exp[a + b], TransformationFunctions -> {f}, ComplexityFunction -> (1 - Count[#1, HoldForm, Infinity, Heads -> True] & )] HoldForm[E^a*E^a] > > I had more luck with > > > > rule = {Exp[a_ + b_] -> f[Exp[a + b]]} > > > > ReplaceRepeated[Exp[a + b], rule] > > > > which gave me Exp[a]Exp[b] > > > > Trying > > > > > > ReplaceRepeated[Exp[a + b + c], rule] > > gave me: > > Exp[a]Exp[b+c] > > > > Why doesn't the TransformationFunction trick work? Why does > > ReplacedRepeated stop? the reason is that Exp[a] is evaluated to E^a, but HoldForm[Exp[a]] is not evaluated to HoldForm[E^a], so you need a double rule: rule = {Exp[a_ + b_] :> HoldForm[Exp[a]*Exp[b]], HoldPattern[Exp[a_ + b_]] :> HoldForm[Exp[a]*Exp[b]]}; Now Exp[a + b + c + d] //. rule HoldForm[E^a*HoldForm[E^b*HoldForm[E^c*E^d]]] which will look fine in Standard or Traditional Form. Andrzej Kozlowski > > > > > > My ultimate goal would be the following: (I need to transfer large > > formulae into C code and would like to avoid use of exponential > function > > as much as possible) > > > > myreplacelist={Exp[var1]->expvar1, Exp[var2]->expvar2} > > myformula=Exp[2 var1 - 3 var2 + a * Exp[var1]]; > > > > ultimate rule applied to my formula gives: > > > > expvar1 * expvar1 / (expvar2 * expvar2 * expvar2) * Exp[a expvar1] > > > > Thanks for your time! > > > > best, > > > > Paul > > > > > > >
- References:
- Hold and Simplify
- From: "news.inode.at" <paul.g.schneider@google.com>
- Hold and Simplify