# Logarithm of exponential [closed]

Ok, this is awkward.

E^Log[a]


gives a, which is what I expected, BUT,

Log[E^a]


is not evaluated at all (I expected the result to be a—this is actually an MWE, what I was trying to do was more complex).

Since I still struggle to understand some of Mathematica's concepts (like when expressions are/n't evaluated), I thought (wrongly, it seems) that it was an Evaluate or Assumptions issue, but now I think it wasn't. I tried:

Assuming[a ∈ Reals, Log[E^a]] // Evaluate
Assuming[a > 0, Log[Exp[a]]] // Simplify


and other variants—which in turn shows that I'm giving a shot in the dark.

What is the explanation for this behavior? How do I get to a? Am I missing an assumption? I don't really care about any weird special cases, a is real, not complex, nor a function, nor anything else.

It obviously seems that I'm missing something (possibly very simple and obvious), but I can't figure out what.

• perhaps reading up on PowerExpand will help you achieve the desired goal Jun 11, 2019 at 18:57

Since Log is a multi-valued inverse function of Exp, Mathematica doesn't evaluate Log[Exp[a]] (or equivalently, Log[E^a]). If you want to simplify these, you need to provide an assumption on the domain of a, e.g.,

Simplify[Log[E^a], a ∈ Reals]


a

or

Simplify[Log[E^a], a > 0]


a

as suggested in the other answer. Another method is to use PowerExpand:

PowerExpand[Log[E^a], Assumptions -> True]


a + 2 I π Floor[1/2 - Im[a]/(2 π)]

As an aside, Log behave exactly like ArcSin here:

ArcSin[Sin[x]]


ArcSin[Sin[x]]

Including a domain restriction:

Simplify[ArcSin[Sin[x]], -Pi/2 < x < Pi/2]


x

For larger domains, Simplify doesn't work:

Simplify[ArcSin[Sin[x]], 0 < x < 2 Pi]


ArcSin[Sin[x]]

Again, using PowerExpand is useful:

p = PowerExpand[ArcSin[Sin[x]], Assumptions -> 0 < x < 2Pi];
p //TeXForm


$$\begin{cases} \pi -x & \frac{\pi }{2}

Visualization:

GraphicsColumn[{
Plot[ArcSin[Sin[x]], {x, 0, 2 Pi}],
Plot[p, {x, 0, 2 Pi}]
}] • Nice explanation! Is there/Shouldn't there be a standard, single valued version of Log, just as the classical, ubiquitous asin, acos, atan? (I know this question may be beyond Mathematica). Is there a mathematical reason for the different treatment? Is it just for historic/convenience/arbitrary reasons? Jun 4, 2019 at 16:10
• @Rafael Log is a standard single valued function when given numerical input. When given symbolic input, Log is not able to figure out the right branch to use without assumptions. This is exactly how ArcSin etc, behave, e.g., ArcSin[Sin[x]] returns it's input. Jun 4, 2019 at 16:17
• I see, silly me. Thanks Jun 4, 2019 at 16:20

The assumption a > 0 is needed when Simplify is called:

Assuming[a > 0, Log[Exp[a]] // Simplify]


a

• a \[Element] Reals works, too. The problem with complex a is that Log[Exp[a + 2 Pi I]] and Log[Exp[a]] are equal. Jun 4, 2019 at 2:59
• Thanks. Is there a good reason why Assuming[a > 0, Log[Exp[a]]] won't just evaluate to a? I don't get it. (cc: @MichaelE2 ) Jun 4, 2019 at 3:01
• @Rafael - The assumptions specified in Assuming only affect functions that take the option Assumptions. Neither Log nor Exp take options. You need to include Simplify or FullSimplify within the Assuming for the assumptions to be used. Jun 4, 2019 at 4:06
• @BobHanlon, Ok, I see. Thank you for your answer. Jun 4, 2019 at 4:40

Logarithm is a problematic function for MMA. I do not know the reason. One can see, for example Log[a] + Log[b] // Simplify returns Log[a] + Log[b] though LeafCount[Log[a] + Log[b]] yields 5, while LeafCount[Log[a*b]] gives 4.

I do not think that in the case Log[E^a] we should use such conditions as a>0 or whatever, since the relation in question is universal. On the other hand, in the case Log[E^a]===a the expression a is doubtless much simpler and, therefore, preferable. It is not that clear what one prefers to have in the case Log[a] + Log[b]

The way around can be using rules. For example, in this case one may use

rule = Log[x_^y_] :> y*Log[x];


Then its application gives

In:= Log[E^a] /. rule

(*   Out= a *)


Have fun!

• Would you say you disagree with the other answers, then? I'd love to read more debate on the issue, if it is somehow contentious Jun 4, 2019 at 12:28
• @Rafael No, I do not. However, they used some conditions imposed on a to achieve the desired results. We know, however, that the relation Log[Exp[a]]===a holds for any a. So, using the relation, say, a>0 is to extent misleading. Indeed, in this case, we know that it holds for any a. However, in a more cumbersome case this condition may lead you into an erroneous assumption that such an inequality is necessary. Anyway, one should be careful. Jun 4, 2019 at 12:52
• @AlexeiBoulbitch the expression isn't general for complex values of a. a > 0 forces a into the reals. Also, consider a = -1 + I, b=-1; the sum of the logs is not the log of the product. Jun 4, 2019 at 14:00
• @AlexeiBoulbitch sorry, I was unclear. I should have split my comment: Log[Exp[a]]===a isn't general for complex values of a (in particular, when Abs[Im[a]] > 2 Pi), but a > 0 forces a into the reals. Furthermore, Log[a] + Log[b] is not, in general, Log[a*b] if a or b are complex. Jun 4, 2019 at 14:39
• In:= Log[Exp[a]] /. a->-1-5*I Out= (-1 - 5 I) + (2 I) Pi So this claimed identity is simply wrong. As has been noted in the comment by @Davidmh Jun 4, 2019 at 16:17