About 51,800 results
Open links in new tab
  1. logarithm - Log to the base 2 in python - Stack Overflow

    Sep 15, 2010 · In python 3 or above, math class has the following functions import math math.log2(x) math.log10(x) math.log1p(x) or you can generally use math.log(x, base) for any base you want.

  2. math - Calculate logarithm in python - Stack Overflow

    Nov 17, 2015 · I am wondering why the result of log base 10 (1.5) in python is 0.405465108108 while the real answer is 0.176091259. This is the code that I wrote: import math print math.log(1.5) Can someone tel...

  3. ln (Natural Log) in Python - Stack Overflow

    I have to create a python script to solve an equation (screenshot). Unfortunately, in my research all over the internet I cannot figure out how in the world to either convert ln to log or anything usable, or anything.

  4. math.log in Python - Stack Overflow

    Feb 8, 2013 · I am writing a Python program to print all the powers of ten before an inputted number. For example, if the input is 12345, the program should output 10, 100, 1000, 10000. Here is my program - im...

  5. Get logarithm without math log python - Stack Overflow

    Nov 3, 2012 · This shows our value compared to the math.log value (separated by a space) and, as you can see, we're pretty accurate. You'll probably start to lose some accuracy as you get very large (e.g. ln(10000) will be about 0.4 greater than it should), but you can always increase n …

  6. How do you do natural logs (e.g. "ln()") with numpy in Python?

    Using numpy, how can I do the following: ln(x) Is it equivalent to: np.log(x) I apologise for such a seemingly trivial question, but my understanding of the difference between log and ln is that ...

  7. Logarithm to base 3 in python - Stack Overflow

    Sep 1, 2023 · Recall that when you write math.log(x, 3), Python is actually calculating something like math.log(x) / math.log(3), with both (natural) log calculations and the division having to be rounded to the nearest float.

  8. c# - What happens in numpy's log function? Are there ways to …

    May 10, 2017 · Which is why math.log is faster for scalars compared to numpy.log. But if you operate on arrays and want to take the logarithm of all elements in the array NumPy can be much faster. On my computer if I time the execution of np.log on an array compared to math.log of each item in a list then the timing looks different: arr = np.arange(1, 10000000)

  9. math - Inaccurate Logarithm in Python - Stack Overflow

    May 31, 2009 · I work daily with Python 2.4 at my company. I used the versatile logarithm function 'log' from the standard math library, and when I entered log(2**31, 2) it returned 31.000000000000004, which stru...

  10. python logarithm - Stack Overflow

    Jun 7, 2009 · You can only compute the logarithm of a positive number. Trying to compute the logarithm for a negative number or zero will result in a "math domain error" in Python. By the way: it looks like you're actually trying to compute a logarithm base 2. You can do this with math.log: w=math.log(q*q1, 2) The second, optional, parameter is the base. It defaults to e (ie: natural log).