np.log is ln, whereas np.log10 is your standard base 10 log.
Top answer 1 of 6
275
np.log is ln, whereas np.log10 is your standard base 10 log.
2 of 6
25
Correct, np.log(x) is the Natural Log (base e log) of x.
For other bases, remember this law of logs: log-b(x) = log-k(x) / log-k(b) where log-b is the log in some arbitrary base b, and log-k is the log in base k, e.g.
here k = e
l = np.log(x) / np.log(100)
and l is the log-base-100 of x
Top answer 1 of 2
93
math.log is the natural logarithm:
From the documentation:
math.log(x[, base]) With one argument, return the natural logarithm of x (to base e).
Your equation is therefore:
n = math.log((1 + (FV * r) / p) / math.log(1 + r)))
Note that in your code you convert n to a str twice which is unnecessary
2 of 2
12
Here is the correct implementation using numpy (np.log() is the natural logarithm)
import numpy as np
p = 100
r = 0.06 / 12
FV = 4000
n = np.log(1 + FV * r/ p) / np.log(1 + r)
print ("Number of periods = " + str(n))
Output:
Number of periods = 36.55539635919235
Videos
03:29
Natural Logarithms in NumPy: Complete np.log() Tutorial for Beginners ...
02:28
How do you do natural logs (e.g. "ln()") with numpy in Python? ...
02:51
how to find log of a number in python | take logarithm of a number ...
00:43
Python log() function | math module | mathematical functions - YouTube
05:01
Log functions in Python | How to Calculate logarithm in python ...
03:49
How to Find Logarithm with Base n in Python - YouTube
W3Schools
w3schools.com › python › ref_math_log.asp
Python math.log() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... # Import math Library import math # Return the natural logarithm of different numbers print(math.log(2.7183)) print(math.log(2)) print(math.log(1)) Try it Yourself »
Codecademy
codecademy.com › docs › python:numpy › math methods › .log()
Python:NumPy | Math Methods | .log() | Codecademy
July 15, 2024 - In NumPy, the .log() method is used to calculate the natural logarithm (base-e) of each element in an array. It is widely used in scientific computations, data analysis, and mathematical applications where logarithmic scaling is essential.
NumPy
numpy.org › doc › stable › reference › generated › numpy.log.html
numpy.log — NumPy v2.4 Manual
The natural logarithm is logarithm in base e.
Scaler
scaler.com › home › topics › how to calculate ln in python
How to Calculate ln in Python? - Scaler Topics
October 10, 2025 - The base value in the case of natural logarithm is e. The Math.log() method of math library can be used to calculate ln in Python.
Codecademy
codecademy.com › docs › python › math module › math.log()
Python | Math Module | math.log() | Codecademy
March 17, 2024 - ... The math.log() function returns a float value, the natural logarithm of n or the logarithm of n to base. If n is 0 or a negative number, it returns a ValueError. Use math.log() to return the natural log of 12 (base e):
GeeksforGeeks
geeksforgeeks.org › python › log-functions-python
Log functions in Python - GeeksforGeeks
August 14, 2024 - Return Value : Returns natural log if 1 argument is passed and log with specified base if 2 arguments are passed. Exceptions : Raises ValueError if a negative no. is passed as argument. ... # Python code to demonstrate the working of # log(a,Base) import math # Printing the log base e of 14 print ("Natural logarithm of 14 is : ", end="") print (math.log(14)) # Printing the log base 5 of 14 print ("Logarithm base 5 of 14 is : ", end="") print (math.log(14,5))
DigitalOcean
digitalocean.com › community › tutorials › python-log-function-logarithm
Python log() Functions to Calculate Logarithm | DigitalOcean
August 4, 2022 - In order to use the functionalities ... We need to use the math module to access the log functions in the code. ... The math.log(x) function is used to calculate the natural logarithmic value i.e....
datagy
datagy.io › home › numpy › python natural log: calculate ln in python
Python Natural Log: Calculate ln in Python • datagy
December 30, 2022 - If no value is provided, the value defaults to e, meaning that by only provided a number, you are automatically calculating the natural logarithm. This may seem counterintuitive – however, recall from the introduction that in many cases the base e is implicit, and many times is omitted when referring to a log() function without a specified base. Let’s see how we can use the Python math library to calculate the natural log.
TutorialsPoint
tutorialspoint.com › compute-the-natural-logarithm-in-python
Compute the Natural Logarithm in Python
The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e. The method returns the natural logarithm of x, elementwise. This is a scalar if x is a scalar. The 1st parameter is the input value, array-like.
GeeksforGeeks
geeksforgeeks.org › python › log-and-natural-logarithmic-value-of-a-column-in-pandas-python
Log and natural Logarithmic value of a column in Pandas - Python - GeeksforGeeks
July 15, 2025 - Name Salary natural_log 0 Geek1 18000 9.798127 1 Geek2 20000 9.903488 2 Geek3 15000 9.615805 3 Geek4 35000 10.463103 · In this example the Python code uses Pandas to create a dataframe ('Column_Name'). It imports the log function from the math module to compute natural logarithmic values for ...