Skip to content
Advertisement

Decimal logs in Sympy

I want to solve an expression in SymPy

JavaScript

But then I try to code it like this

JavaScript

The result isn’t correct.

Advertisement

Answer

You’ve got the result with ten digits, and not the decimal logarithm. Documentation says,

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.

You can divide result by log(10) or define your own function, like this:

JavaScript

Anyway, to get the desired result, you should use either simplify(expr).evalf() or N(expr):

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement