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

Answer from Diziet Asahi on Stack Overflow
🌐
Python
docs.python.org › 3 › library › math.html
math — Mathematical functions
2 weeks ago - This module provides access to common mathematical functions and constants, including those defined by the C standard. These functions cannot be used with complex numbers; use the functions of the ...
🌐
W3Schools
w3schools.com › python › ref_math_log.asp
Python math.log() Method
The math.log() method returns the natural logarithm of a number, or the logarithm of number to base. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you ...
🌐
Scaler
scaler.com › home › topics › how to calculate ln in python
How to Calculate ln in Python? - Scaler Topics
October 10, 2025 - The Math.log() method of math library can be used to calculate ln in Python.
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › log
Python Numpy log() - Calculate Natural Logarithm | Vultr Docs
November 15, 2024 - Click below to sign up and get $250 of credit to try our products over 30 days · The log() function from the Numpy library in Python is a versatile tool for computing the natural logarithm of an array of numbers, where the natural logarithm ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › log-functions-python
Log functions in Python - GeeksforGeeks
August 14, 2024 - Syntax : math.log2(a) Parameters : a : The numeric value Return Value : Returns logarithm base 2 of a Exceptions : Raises ValueError if a negative no. is passed as argument. ... # Python code to demonstrate the working of # log2(a) import math # Printing the log base 2 of 14 print ("Logarithm base 2 of 14 is : ", end="") print (math.log2(14))
🌐
Centron
centron.de › startseite › python log() function to calculate logarithm
Python log() Function to Calculate Logarithm
February 7, 2025 - Python provides several variants of the log() function to calculate logarithms to specific bases or in unique scenarios: ... The math.log2(x) function computes the logarithm of x to the base 2, commonly used in computer science.
Find elsewhere
🌐
datagy
datagy.io › home › numpy › python natural log: calculate ln in python
Python Natural Log: Calculate ln in Python • datagy
December 30, 2022 - Learn how to use Python to calculate the natural log (logarithm), known as ln, using the math and numpy libraries, and how to plot it.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.log.html
numpy.log — NumPy v2.1 Manual
M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Power and Logarithmic Functions in Python: exp, log, log10, log2 | note.nkmk.me
August 10, 2023 - If the second argument is omitted, ... a base of e and is represented in mathematics by "log" or "ln", can be calculated using math.log(x)....
🌐
Python Forum
python-forum.io › thread-2599.html
Natural Logarithm in Python
OHello all, I'm relatively new at Python; I need to input an equation, but I need help with expressing the Natural Logarithm in Python (ln): The equation is: (7.35 x E) + [17.34 x ln(Len)] + [4.96 x ln(Conc)] + [0.89 x ln(DNA)] - 25.42 E, Len, ...
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.log.html
numpy.log — NumPy v2.5.dev0 Manual
M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp.
🌐
KooR.fr
koor.fr › Python › API › python › math › log.wp
KooR.fr - Fonction log - module math - Description de quelques librairies Python
Deep Learning avec Python et Keras ... float · Cette fonction calcule le logarithme de la valeur spécifiée en premier paramètre dans la base spécifiée en second paramètre (par défaut, en base e). Si la base (second paramètre) n'est pas spécifiée, la fonction calcule le logarithme naturel (en base e). le logarithme naturel (ou népérien) est dit de base e car ln(e) = 1....
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-log-python
numpy.log() in Python - GeeksforGeeks
January 13, 2026 - Python numpy-Mathematical Function · Python Fundamentals · Python Introduction2 min read · Input and Output in Python4 min read · Python Variables4 min read · Python Operators4 min read · Python Keywords2 min read · Python Data Types8 min read · Conditional Statements in Python3 min read ·
🌐
Pythonforundergradengineers
pythonforundergradengineers.com › exponents-and-logs-with-python.html
Exponents and Logs with Python - Python for Undergraduate Engineers
June 27, 2022 - The following exponent and logarithm functions can be imported from Python's math module: ... Note that Python's log function calculates the natural log of a number. Python's log10 function calculates the base-10 log of a number. Python doesn't have an ln function, use log for natural logarithms.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.log.html
numpy.log — NumPy v2.4 Manual
M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp.
🌐
Enterprise DNA
blog.enterprisedna.co › python-natural-log
Python Natural Log: Quick Guide for Calculations – Master Data Skills + AI
The natural logarithm (often abbreviated as “ln”) in Python is a mathematical function that calculates the logarithm of a number to the base ‘e’, where ‘e’ is Euler’s number, approximately equal to 2.71828. It’s widely used in many areas of science and engineering.