0
$\begingroup$

How can I require Mathematica to format an expression like Exp[x] x^s as Exp[x + s Log[x]]?

$\endgroup$
  • 1
    $\begingroup$ People here generally like users to post code as Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this meta Q&A helpful. (You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is useful for learning how to format your questions and answers) $\endgroup$ – Michael E2 Apr 30 at 13:26
  • $\begingroup$ I would just do it manually: expr = Exp[x] x^s; Assuming[ x > 0 && s > 0, (Exp@*FullSimplify@*Log)[expr]]. $\endgroup$ – Thies Heidecke Apr 30 at 13:44
  • $\begingroup$ Exp[z] automatically evaluates to Power[E, z], so I don't think there is. There is a way to format output in the way you indicate, but the internal representation willl revert to Power. $\endgroup$ – Michael E2 Apr 30 at 13:55
2
$\begingroup$

The following code

Exp[x] x^s /. {a_^b_ :> Exp[log[a] b]} /. log -> Log // InputForm

returns the result

E^(x + s*Log[x])

which is what I think you wanted. By comparison, the original expression

Exp[x] x^s // InputForm

returns the result

E^x*x^s
$\endgroup$
1
$\begingroup$

Method for output formatting:

MakeBoxes[Power[b_, p_], form_] := 
 With[{p2 = p*Log[b]}, MakeBoxes[Exp[p2], form]];
MakeBoxes[Times[pow__Power, c__], form_] := MakeBoxes[Times[c, Times[pow]]];
MakeBoxes[Times[pow__Power], form_] := 
 With[{p2 = 
    With[{terms = List @@@ {pow}}, 
     Total[terms[[All, 2]] Log[terms[[All, 1]]]]]}, 
  MakeBoxes[Exp[p2], form]]

Exp[x] x^s
(*  Exp[x + s Log[x]]  *)

2 + y Exp[x] x^s
(*  2 + y Exp[x + s Log[x]]  *)

I don't know if this is desired, but it shows that all powers are converted to Exp[]:

x^2
(*  Exp[2 Log[x]]  *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.