How to simplify expressions in Mathematica with log and exp in them?

You can see this by trying different values of z and seeing where the logarithm cuts the real axis. This discontinuity can be a source of error when using the logarithm in complex contexts.In summary, z is a real or complex number that must be used with care when representing it as a variable in Mathematica because the order of operations may not be preserved when composing Log[z] with other Mathematica functions. If z is real, using PowerExpand[] will ensure that the correct branch cut is used, but if z is complex, using Log[z] may lead to an error.f
  • #1
611
116
TL;DR Summary
How can I get the expression ## log(exp(z)) ## to return ## z ## in Mathematica?
Hi,

This is a pretty simple question, but I am new to Mathematica so I am not sure if I am missing something obvious.

Question: How do I make the expression ## e^{log(z)} ## return z?

Attempt:

I have used all of the following combinations and all of them return ## e^{log(z)}##. Are there any tips people have? I have seen some people online use some elaborate functions, but I am just looking for a simple(r) solution.

Mathematica:
e^log[z]
E^log[z]
PowerExpand[E^log[z]]
Simplify[PowerExpand[E^log[z]]]

Thanks in advance.
 
  • #4
PowerExpand[] works for me. Be sure to capitalize Log , Exp and E !

In[1]:= PowerExpand[Log[Exp[z]]]

Out[1]= z
 
  • Like
  • Wow
Likes jedishrfu and Master1022
  • #5
PowerExpand[] works for me. Be sure to capitalize Log , Exp and E !

In[1]:= PowerExpand[Log[Exp[z]]]

Out[1]= z
Oh wow, that does work! Many thanks. Do you know of any reason why using an upper case Log[] inside a Solve[] function could lead to an error, but then I changed it to log[] (lower case) and the error went away).
 
  • #6
Do you know of any reason why using an upper case Log[] inside a Solve[] function could lead to an error, but then I changed it to log[] (lower case) and the error went away).
To answer I'd have to see how you set up your Solve[] statement. Can you share it?
 
  • #7
@Master1022, in your first post you asked two different questions:
How can I get the expression ##\log(exp(z))## to return z in Mathematica?
Question: How do I make the expression ##e^{\log(z)} return z?

First off, is z a complex number? A variable named z is often used to represent a complex number, so if you use z to represent a real number, that can lead to confusion amongst readers.

Mathematically, ##\log(exp(z))## is always defined and is equal to z, but the opposite order in the composition may not be defined due to ##\log(z)## not being defined. If z is real, log(z) is defined only for z > 0.

If z is complex, the Mathematica documentation says this:
Log[z] has a branch cut discontinuity in the complex z plane running from ##-\infty## to 0.
 

Suggested for: How to simplify expressions in Mathematica with log and exp in them?

Replies
1
Views
446
Replies
10
Views
1K
Replies
10
Views
1K
Replies
7
Views
1K
Replies
6
Views
910
Replies
1
Views
887
Replies
1
Views
687
Replies
2
Views
929
Back
Top