Group Abstract Group Abstract

Message Boards Message Boards

0
|
39 Views
|
5 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Simplify not fully expanding complex exponential product

Posted 2 days ago

Simplify function not fully expanding a specific complex exponential product. Exp[ a x] * Exp[ b x] stay as E^( (a + b) x) even with TargetFunctions->{Re,Im}. Pretty sure this worked differently in version 12.3, seems to require ComplexExpand now which is kinda unexpected.

POSTED BY: Connor Hayes
5 Replies

Power[] combines products with the same base automatically.

Exp[a x]*Exp[b x]
(*  E^(a x + b x)  *)

Power[c, a x]*Power[c, b x]
(*  c^(a x + b x)  *)

You cannot keep the factors separate except by preventing Times[] from evaluating, with one of the Hold* functions, Defer[], or Inactive as Gianluca shows.

I don't quite understand how you used ComplexExpand[] here.

If you're trying to get the output to look a certain way, here are some tools, assuming you wish to compute the output instead of typing it by hand. FactorList[] returns separate, unmultiplied factors in the form {base, exponent}. Power[] can be used to convert a pair back to exponential form. Times[] can be used to multiply the exponential forms. Unless you've done something in between, Times[] will return to the original expression, more or less:

FactorList@ExpandAll[Exp[(a + b) x]]
(*  {{1, 1}, {E^(b x), 1}, {E^(a x), 1}}  *)

Power @@@ FactorList@ExpandAll[Exp[(a + b) x]]
(*  {1, E^(b x), E^(a x)}  *)

Times @@ Power @@@ FactorList@ExpandAll[Exp[(a + b) x]]
(*  E^(a x + b x)  *)

To keep the exponentials from combining, we need to do something before multiplying. All four example codes show an output that looks like E^(b x) E^(a x). The first two return a held form of E^(b x) E^(a x) which prints out with HoldForm invisible. The last two codes output E^(b x) E^(a x) having "deferred" the evaluation of the expression.

Times @@ 
 Replace[Power @@@ FactorList@ExpandAll[Exp[(a + b) x]], 
  e : Except[_?NumericQ] :> HoldForm[e], 1]

Times @@ 
  HoldForm /@ Power @@@ FactorList@ExpandAll[Exp[(a + b) x]] /. 
 HoldForm[n_?NumericQ] :> n
(*  HoldForm[E^(a*x)]*HoldForm[E^(b*x)] *)

Times @@ Hold /@ Power @@@ FactorList@ExpandAll[Exp[(a + b) x]] /. 
   HoldForm[n_?NumericQ] :> n // Defer[#] & // 
 ReplaceAll[Hold[e_] :> e]

Defer[#] &@
  Replace[Power @@@ FactorList@ExpandAll[Exp[(a + b) x]], 
   List[n___?NumericQ, e : Except[_?NumericQ] ...] :> 
    n*Hold[Times[e]]] /. Hold[e_] :> e
(*  E^(b x) E^(a x)  *)

Obviously, working with FactorList[] takes some work. Part of the problem here is that I wanted the output to be E^(b x) E^(a x) and not 1 E^(b x) E^(a x). To get that, I needed to let Times[] evaluate the numeric factors but not the exponential factors. To do different things to the factors introduces complexity that is unavoidable.

POSTED BY: Michael Rogers

Slightly less complicated:

Times @@ Defer /@ Power @@@ FactorList[E^(a x + b x)] /. 
 Defer[n_?NumericQ] :> n
(*  E^(a x) E^(b x)  *)
POSTED BY: Michael Rogers

The expression E^( (a + b) x) is simpler than Exp[ a x] * Exp[ b x] for the default ComplexityFunction. I am afraid that Simplify will not do what you want. To keep the two exponentials from combining, you must stop the standard evaluation, for example using Inactive:

Inactive[Times][Exp[a x], Exp[b x]]
POSTED BY: Gianluca Gorni
Posted 17 hours ago

Thanks for the suggestion! I should clarify that my goal isn't to keep the exponentials separate but to have Simplify expand E^((a+b)x) into its real and imaginary parts (sin/cos terms) when a and b are complex, similar to what ComplexExpand does. Is there a way to get Simplify to do this automatically via TargetFunctions, or has that behavior changed since v12.3?

POSTED BY: Updating Name

Assuming x is real, a and b are complex, perhaps the following:

ComplexExpand[E^((a + b) x), {a, b}] (* 2nd arg. assumed to be complex-valued *)

I can't remember how it worked in V12. The revision history in the docs suggests that the last (major) change was in V6.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard