# Require an expression to be formatted as an exponential expression

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

• 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) Apr 30, 2019 at 13:26
• I would just do it manually: expr = Exp[x] x^s; Assuming[ x > 0 && s > 0, (Exp@*FullSimplify@*Log)[expr]]. Apr 30, 2019 at 13:44
• 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. Apr 30, 2019 at 13:55

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


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]]  *)