About 46,900 results
Open links in new tab
  1. Exponentials in python: x**y vs math.pow (x, y) - Stack Overflow

    Jan 7, 2014 · I removed the timing comparison of math.pow(2,100) and pow(2,100) since math.pow gives a wrong result whereas, for example, the comparison between pow(2,50) and math.pow(2,50) would have been fair (although not a realistic use of the math-module function). I added a better one and also the details that cause the limitation of math.pow.

  2. How did Python implement the built-in function pow ()?

    Mar 9, 2011 · Line 1426 of this file shows the Python code that implements math.pow, but basically it boils down to it calling the standard C library which probably has a highly optimized version of that function. Python can be quite slow for intensive number-crunching, but Psyco can give you a quite speed boost, it won't be as good as C code calling the ...

  3. Difference between the built-in pow() and math.pow() for floats, in …

    Apr 23, 2012 · Is there a difference in the results returned by Python's built-in pow(x, y) (no third argument) and the values returned by math.pow(), in the case of two float arguments. I am asking this question because the documentation for math.pow() implies that pow(x, y) (i.e. x**y) is essentially the same as math.pow(x, y): math.pow(x, y)

  4. Python pow () and modulus - Stack Overflow

    Jun 9, 2021 · The pow() function in Python3 provide the values for exponents. >>>pow(2, 3) 8 Python3 has support to negative exponents that is can be represented using pow(10, -1).

  5. calculate mod using pow function python - Stack Overflow

    Sep 23, 2015 · It's simple: pow takes an optional 3rd argument for the modulus. From the docs:. pow(x, y[, z]) Return x to the power y; if z is present, return x to the power y, modulo z (computed more efficiently than pow(x, y) % z).

  6. python - Why is time complexity O (1) for pow (x,y) while it is O (n ...

    Feb 17, 2018 · pow (see here) and ** (see here) both call the same PyNumber_Power function. In practice, ** can be faster, because it avoids the overhead of an extra symbol lookup and function call. The integer implementation of pow / ** can be seen here. math.pow, on the other hand, always calls the C library's pow function

  7. Modular multiplicative inverse function in Python

    Sympy, a python module for symbolic mathematics, has a built-in modular inverse function if you don't want to implement your own (or if you're using Sympy already): from sympy import mod_inverse mod_inverse(11, 35) # returns 16 mod_inverse(15, 35) # raises ValueError: 'inverse of 15 (mod 35) does not exist'

  8. python - Negative power in modular pow () - Stack Overflow

    Dec 6, 2015 · pow(10, -2) produces 0.01, for example, so your statement that python won't work with negative number is at the very least a misunderstanding on your part. – Martijn Pieters Commented Dec 6, 2015 at 15:33

  9. performance - Which is faster in Python: x**.5 or math.sqrt (x ...

    In python 2.6 the (float).__pow__() function uses the C pow() function and the math.sqrt() functions uses the C sqrt() function. In glibc compiler the implementation of pow(x,y) is quite complex and it is well optimized for various exceptional cases. For example, calling C pow(x,0.5) simply calls the sqrt() function.

  10. function - Raising to powers in C++ vs. Python - Stack Overflow

    There are several modes for use of this function and every time you send different variables to it, system decides which mode to choose . pow( float base, float exp ); and pow( double base, double exp ); are not the same and each are a separate function. Now when you go to the Python there are exactly same state .

Refresh