Logarithm Calculator

Logarithm Calculator

log₁₀(x) — Common Log
ln(x) — Natural Log
log₂(x) — Binary Log
logₙ(x) — Custom Base

Logarithm Calculator – log, ln, log₂, and Custom Base

This free online logarithm calculator computes four logarithm values simultaneously: the common logarithm (log₁₀), the natural logarithm (ln), the binary logarithm (log₂), and any custom base you specify. Enter a positive number and get all results instantly, with the full change-of-base formula shown.

What Is a Logarithm?

A logarithm answers the question: "To what power must the base be raised to produce this number?" If b^y = x, then log_b(x) = y. For example, log₁₀(1000) = 3 because 10³ = 1000. Logarithms are the inverse of exponential functions, much like subtraction is the inverse of addition.

The Three Common Logarithm Bases

  • Base 10 (log₁₀ or "log"): The common logarithm. Used in pH scales, the Richter scale for earthquakes, and decibel (dB) sound levels. log₁₀(100) = 2, log₁₀(1000) = 3.
  • Base e (ln, natural logarithm): Where e ≈ 2.71828. Used in calculus, exponential growth and decay, probability, and information theory. ln(e) = 1, ln(1) = 0.
  • Base 2 (log₂, binary logarithm): Used in computer science, information theory, and algorithm complexity. log₂(8) = 3, log₂(1024) = 10.

Change of Base Formula

Any logarithm can be computed using the natural log: log_b(x) = ln(x) / ln(b). This is how the custom base calculation works in this tool — it uses JavaScript's native Math.log() (which computes ln) and divides by ln(b). For example, log_3(81) = ln(81) / ln(3) = 4.394 / 1.099 = 4.

Real-World Applications of Logarithms

  • pH scale: pH = −log₁₀([H⁺]). A pH of 7 means [H⁺] = 10⁻⁷ mol/L.
  • Decibels: dB = 10 × log₁₀(P₂/P₁). Sound intensity comparison.
  • Richter scale: Each integer step represents a 10× increase in amplitude.
  • Compound interest: Time to double = ln(2) / ln(1 + r), where r is the interest rate.
  • Algorithm complexity: Binary search runs in O(log₂ n) time.
  • Radioactive decay: t½ = ln(2) / λ, where λ is the decay constant.

Frequently Asked Questions

Why is the logarithm undefined for zero and negative numbers?
No real power of a positive base produces zero or a negative number. For example, 10^x is always positive for any real x. Therefore log(0) and log(negative) are undefined in real number mathematics.
What is the natural logarithm (ln) used for?
The natural logarithm is the logarithm to base e (Euler's number ≈ 2.718). It arises naturally in calculus as the antiderivative of 1/x, and in models of continuous growth and decay (population, radioactive decay, compound interest with continuous compounding).
What is log base 2 used for in computing?
Binary logarithm tells you how many bits are needed to represent a number, and how many times you can halve a dataset (relevant for binary search and tree structures). log₂(1,048,576) = 20, meaning you need 20 bits or 20 bisection steps.
Can base 1 be used as a logarithm base?
No. 1 raised to any power is always 1, so there is no solution to 1^y = x for x ≠ 1. Base 1 (and base 0) are invalid for logarithms. The calculator will reject base 1 with an explanation.
How do I calculate log₅(125)?
Enter 125 as the number and 5 as the custom base. The result is 3 because 5³ = 125. You can verify: 10^(log₁₀(125)/log₁₀(5)) = 10^(2.097/0.699) = 10^3 = 1000. Wait — actually log₅(125) = log(125)/log(5) = 3 exactly.