Sympy returns log instead of ln
Question:
I have this equation:
import sympy as sp
x = sp.Symbol(‘x’, real = True)
fx = sp.log(x,3)
sp.diff(fx, x)
Sympy returns:
1/(x*log(3))
Sympy should return:
1/(x*ln(3))
Why is Sympy returning the log function rather than the natural log function?
Answers:
From 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)
So the code you have posted is in fact, correct.
sp.log(x,3)
is equivalent to log(x)/log(3)
, and the derivative of this is 1/(x*log(3))
which in Sympy is equivalent to 1/(x*ln(3))
.
ln = pronounce "log in"
I have this equation:
import sympy as sp
x = sp.Symbol(‘x’, real = True)
fx = sp.log(x,3)
sp.diff(fx, x)
Sympy returns:
1/(x*log(3))
Sympy should return:
1/(x*ln(3))
Why is Sympy returning the log function rather than the natural log function?
From 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)
So the code you have posted is in fact, correct.
sp.log(x,3)
is equivalent to log(x)/log(3)
, and the derivative of this is 1/(x*log(3))
which in Sympy is equivalent to 1/(x*ln(3))
.
ln = pronounce "log in"