Reputation: 88158
How can I get sympy to simplify an expression like log(exp(exp(x)))
to exp(x)
? It seems to work on simpler expressions like exp(log(x))
=> x
. This is a minimal example showing what I've tried so far:
import sympy
from sympy import exp, log
x = sympy.symbols('x')
a = exp(log(x))
print a
# Gives `x` automatically, no call to simplify needed
b = log(exp(exp(x)))
print sympy.simplify(b), sympy.powsimp(b,deep=True)
# Gives `log(exp(exp(x)))` back, expected `exp(x)`
Upvotes: 2
Views: 688
Reputation: 2094
This is happening because of lack of information. I think you want to do this:
In [7]: x = Symbol('x', real=True)
In [8]: (log(exp(exp(x)))).simplify()
Out[8]: exp(x)
Upvotes: 3