Logarithm Calculator
Calculate logarithms in any base — natural log (ln), log base 10, or custom base.
About this tool
A logarithm is the inverse operation of exponentiation—it answers the question: what power must I raise a base to in order to get a specific number? This calculator helps you find logarithms quickly in any base, whether you need the natural logarithm (ln), logarithm base 10, or a custom base. Understanding logarithms is essential for fields ranging from computer science and mathematics to physics, chemistry, and engineering.
Using this tool is straightforward: enter the number for which you want to find the logarithm, select your preferred base (or enter a custom base), and the calculator instantly displays the result. You can explore how logarithms work by experimenting with different bases and values—for example, log₂ of 8 equals 3 because 2³ = 8. Common applications include calculating pH levels in chemistry, measuring the complexity of algorithms in computer science, and solving exponential equations in mathematics.
Frequently Asked Questions
Code Implementation
import math
# Common logarithms
print(math.log10(1000)) # 3.0 — log base 10
print(math.log2(1024)) # 10.0 — log base 2
print(math.log(math.e)) # 1.0 — natural log (ln)
# Arbitrary base using change-of-base formula
def log_base(x: float, base: float) -> float:
"""log_base(x) = ln(x) / ln(base)"""
return math.log(x) / math.log(base)
print(log_base(8, 2)) # 3.0
print(log_base(1000, 10)) # 3.0
print(log_base(81, 3)) # 4.0
# Logarithm rules examples
a, b = 100, 10
print(math.log10(a * b) == math.log10(a) + math.log10(b)) # True (product rule)
print(math.log10(a / b) == math.log10(a) - math.log10(b)) # True (quotient rule)
print(math.log10(a ** 3) == 3 * math.log10(a)) # True (power rule)
# Inverse: e^ln(x) = x
x = 42
print(abs(math.e ** math.log(x) - x) < 1e-10) # TrueComments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.