Search notes:

Python library math - logarithmic functions

import math

#
#  log(x) - natural logarithm of x
#
print(math.log(math.e))  # --> 1

#
#  log(x, b) - logarithm of x to the given base
#
print(math.log(256, 4)) # --> 4.0

#
#  log10(x) - base 10 logarithm of x ( usually more accurate than log(x, 10) )
#
print(math.log10(1000)) # --> 3.0

#
#  log2(x) - base 2 logarithm of x   ( usually more accurate than log(x, 2) )
#
print(math.log2(256))       # --> 8.0

#
#  log1p(x) == log(x+1)  (calculated in a way which is accurate for x near zero)
#
print(math.log1p(math.e-1)) # --> 1.0


Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758203932, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/standard-library/math/log_(56): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78