Sympy returns log 而不是 ln
Sympy returns log instead of ln
我有这个等式:
import sympy as sp
x = sp.Symbol(‘x’, real = True)
fx = sp.log(x,3)
sp.diff(fx, x)
同情 returns:
1/(x*log(3))
Sympy 应该 return:
1/(x*ln(3))
为什么 Sympy return 使用对数函数而不是自然对数函数?
来自here:
Note:
In SymPy, as in Python and most programming languages, log is the natural logarithm, also known as ln. SymPy automatically provides an alias ln = log in case you forget this.
>>> sp.ln(x)
log(x)
所以您发布的代码实际上是正确的。
sp.log(x,3)
等价于 log(x)/log(3)
,其导数是 1/(x*log(3))
,在 Sympy 中等价于 1/(x*ln(3))
.
我有这个等式:
import sympy as sp
x = sp.Symbol(‘x’, real = True)
fx = sp.log(x,3)
sp.diff(fx, x)
同情 returns:
1/(x*log(3))
Sympy 应该 return:
1/(x*ln(3))
为什么 Sympy return 使用对数函数而不是自然对数函数?
来自here:
Note:
In SymPy, as in Python and most programming languages, log is the natural logarithm, also known as ln. SymPy automatically provides an alias ln = log in case you forget this.
>>> sp.ln(x)
log(x)
所以您发布的代码实际上是正确的。
sp.log(x,3)
等价于 log(x)/log(3)
,其导数是 1/(x*log(3))
,在 Sympy 中等价于 1/(x*ln(3))
.