vic
vic

Reputation: 55

Sympy returns log instead of ln

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?

Upvotes: 5

Views: 16178

Answers (1)

CDJB
CDJB

Reputation: 14546

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)).

Upvotes: 9

Related Questions