# Recursive ReplaceRepeated fails

Posted 10 years ago
3452 Views
|
5 Replies
|
1 Total Likes
|
 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!
5 Replies
Sort By:
Posted 10 years ago
 You could do output /. Expand -> Identity...It should do it automatically though....
Posted 10 years ago
 Thanks Sanders !
Posted 10 years ago
 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.
Posted 10 years ago
 Many thanks Sean !Absent-mindedness affair !Regards
Posted 10 years ago
 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 ?RegardsSylvain