gpt4 book ai didi

python - Sympy 返回 log 而不是 ln

转载 作者:行者123 更新时间:2023-12-01 00:12:01 25 4
gpt4 key购买 nike

我有这个等式:

import sympy as sp

x = sp.Symbol(‘x’, real = True)
fx = sp.log(x,3)

sp.diff(fx, x)

Sympy 返回:

1/(x*log(3))

Sympy 应该返回:

1/(x*ln(3))

为什么 Sympy 返回对数函数而不是自然对数函数?

最佳答案

来自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))

关于python - Sympy 返回 log 而不是 ln,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59575202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com