rousseau
(Sylvain Rousseau)
November 20, 2013, 5:51pm
1
Hi !
I’ve developed a little function to split an exponential in 2 if its argument is a sum :
replace[e_] := e //. Exp[x_ + y_] :> HoldForm[E^x E^y];
Here is the Failing case :
xx = ReleaseHold[
E^(-(((1 + r) (t - t1))/(2 Q tau)) - t/tau1 - t1/tau1)];
xx = replace[xx]; xx = replace[xx]
Here is the reult :
May I ask you why the function does not operate recursively despite the use of //. (ReplaceRepeated[ ]) ?
Cheers!
seanc
(Sean Clarke)
November 20, 2013, 6:17pm
2
If you look closely at the output of replace, you see that there is nothing that matches the form:
Exp[x_ + y_]
Instead, you only see “E” to the power of “some product”. Yes this might be a product of sums, but Mathematica will not expand out the products unless it is told to do so.
You may consider using Expand first:
exponent = Expand[(-(((1 + r) (t - t1))/(2 Q tau)) - t/tau1 - t1/tau1)]
You can then run:
replace[Exp[exponent]]
Or you may consider building Expand into your definition of replace.
rousseau
(Sylvain Rousseau)
November 21, 2013, 9:25am
3
Many thanks Sean !
Absent-mindedness affair !
Regards
rousseau
(Sylvain Rousseau)
November 21, 2013, 10:11am
4
Dear Sean,
I 'am trapped in a new pitfall.. here my new code :
replace[e_] := Module[
{z},
z = e /. Exp[x_] :> Exp[Expand[x]];
z = z //. Exp[u_ + v_] :> HoldForm[E^u E^v]
];
Here is the result :
May I ask you how to remove this Expand[] from the result ?
Regards
Sylvain
sghuisman
(Sander Huisman)
November 21, 2013, 11:44pm
5
You could do
output /. Expand -> Identity
…
It should do it automatically though…