当我输入
import sympy as sp
x = sp.Symbol('x')
sp.simplify(sp.log(sp.exp(x)))
我知道了
log(e^x)
而不是x.我知道这个功能“没有保证”.
Question. Is there some specific simplification (through series expansion or whatsoever) to convert logarithm of exponent into identity function?
解决方法:
您必须将x设置为实际类型,并且您的代码将起作用:
import sympy as sp
x = sp.Symbol('x', real=True)
print(sp.simplify(sp.log(sp.exp(x))))
输出:x.
对于复数x,此公式的结果并不总是等于x.例子是here.