Math

Logarithm Calculator — Any Base

Calculator Free · Private
Reviewed by: (política editorial ) · Last reviewed:
Was this calculator helpful?

A logarithm answers the question: "To what power must base b be raised to produce x?" Formally, log_b(x) = y means b^y = x. This calculator computes the logarithm of any positive number x to any valid base b (b > 0, b ≠ 1) using the change-of-base formula: log_b(x) = ln(x) / ln(b). Common special cases include the common logarithm (base 10, written log₁₀ or simply log) and the natural logarithm (base e ≈ 2.71828, written ln). Logarithms are fundamental in science, engineering, finance, and information theory — from measuring earthquake magnitude and sound intensity to calculating compound interest doubling time and binary storage requirements.

Last reviewed: June 3, 2026 Verified by Source: NIST Digital Library of Mathematical Functions — Logarithm Function (§4.2), NIST Chemistry WebBook — pH and Hydrogen Ion Activity, Wikipedia — Logarithm, Wikipedia — Richter Magnitude Scale 100% private

To calculate a logarithm with any base, use the change-of-base formula: **log_b(x) = ln(x) / ln(b)**. Example: log₂(1024) = ln(1024)/ln(2) = 6.9315/0.6931 = **10** (because 2¹⁰ = 1024). For log₁₀(1000) = 3, log₂(256) = 8, log₅(3125) = 5.

When to use this calculator

  • Calculating the Richter magnitude of an earthquake: M = log₁₀(A/A₀), where A is the measured wave amplitude and A₀ is a reference amplitude — a magnitude-7 quake has 10× the amplitude of a magnitude-6.
  • Determining how many bits are needed to represent N distinct values in computer science: bits = log₂(N), so encoding 256 colors requires log₂(256) = 8 bits.
  • Finding the pH of a solution in chemistry: pH = −log₁₀[H⁺], so a hydrogen-ion concentration of 0.001 mol/L gives pH = −log₁₀(0.001) = 3 (acidic).
  • Computing the doubling time of an investment using the Rule of 72 refinement: exact doubling time = log(2)/log(1 + r), e.g., at 6% annual interest, t = log(2)/log(1.06) ≈ 11.9 years.
  • Converting between decibel levels in acoustics: dB = 10 · log₁₀(P/P₀), so a sound 1000× more intense than the reference measures 10 · log₁₀(1000) = 30 dB louder.
  • Estimating the number of digits in a large integer N: digit count = ⌊log₁₀(N)⌋ + 1, so log₁₀(1,000,000) = 6, confirming 1,000,000 has 7 digits.

Worked Example

  1. Find log₂(1024): x = 1024, b = 2
  2. log₂(1024) = ln(1024) / ln(2) = 6.9315 / 0.6931 = 10
  3. Verify: 2¹⁰ = 1,024 ✓
Result: log₂(1024) = 10

How it works

3 min read

How the Logarithm is Calculated

The calculator uses the change-of-base formula, which expresses any logarithm in terms of natural logarithms:

log_b(x) = ln(x) / ln(b)

Equivalently, using base-10 logs:

log_b(x) = log₁₀(x) / log₁₀(b)

Domain constraints:

  • x > 0 (logarithm of zero or a negative number is undefined in the reals)

  • b > 0 and b ≠ 1 (base 1 would require 1^y = x, which only works for x = 1)
  • Worked step-by-step example:
    Find log₅(3125).
    1. Recognize: does 5^y = 3125? Try y = 5 → 5⁵ = 3125 ✓
    2. Via formula: ln(3125)/ln(5) = 8.0472/1.6094 = 5.0000

    ---

    Reference Table — Common Logarithm Values

    The table below shows benchmark values across the most common bases. Memorizing a few anchors speeds up mental estimation.

    xlog₂(x)log₃(x)log₅(x)log₁₀(x)ln(x) [base e]
    100000
    210.63090.43070.30100.6931
    421.26190.86140.60211.3863
    831.89281.29200.90312.0794
    103.32192.09591.430712.3026
    1642.52371.72271.20412.7726
    3253.15462.15341.50513.4657
    1006.64394.19182.861424.6052
    25685.04743.44542.40825.5452
    1,0009.96586.28774.292036.9078
    1,024106.29954.30083.01036.9315
    1,000,00019.931612.57548.5840613.8155

    ---

    Typical Cases

    Case 1 — Earthquake Magnitude (Richter Scale)


    The 1906 San Francisco earthquake had an estimated amplitude ratio A/A₀ ≈ 10^7.9.
    M = log₁₀(10^7.9) = 7.9

    A quake of M = 8.9 (like the 2011 Tōhoku event) has 10^(8.9 − 7.9) = 10× the wave amplitude.

    Case 2 — Binary Storage


    A database needs to store unique IDs for 50,000 users.
    bits needed = ⌈log₂(50,000)⌉ = ⌈15.6096⌉ = 16 bits

    A 16-bit unsigned integer (max 65,535) is sufficient; a 15-bit field (max 32,767) would overflow.

    Case 3 — Investment Doubling Time


    An index fund averages 7% annual return. Exact doubling time:
    t = log(2) / log(1.07) = 0.6931 / 0.06766 ≈ 10.24 years

    The classic "Rule of 72" gives 72/7 ≈ 10.3 years — close, but the logarithmic formula is exact.

    ---

    Common Errors

    1. Taking log of a non-positive number. log₁₀(0) and log₁₀(−5) are undefined in real numbers.

    2. Confusing log (base 10) with ln (base e). In most US math textbooks "log" without a subscript means base 10. In many science and engineering contexts it means base e. The difference is a factor of ln(10) ≈ 2.3026.

    3. Using base b = 1. log₁(x) is undefined because 1^y = 1 for every y. The denominator ln(1) = 0 produces a division-by-zero error.

    4. Misapplying the product rule. log_b(x · y) = log_b(x) + log_b(y) is valid only when both logarithms share the same base.

    5. Forgetting the negative sign in pH. pH = −log₁₀[H⁺]. Omitting the minus sign turns an acidic solution (pH 3) into a negative number.

    6. Rounding intermediate results. When chaining logarithms, rounding ln(x) to 2 decimal places before dividing by ln(b) can introduce errors of several percent. Carry full precision until the final step.

    ---

    Related Calculators

  • Scientific Notation Converter — uses log₁₀ to determine the order of magnitude

  • Compound Interest Calculator — doubling time derived from log(2)/log(1+r)

  • Percentage Calculator — percent change problems often involve log scaling
  • Frequently asked questions

    How do I calculate log base 2 of a number?

    Use the change-of-base formula: log₂(x) = ln(x) / ln(2). For example, log₂(1024) = ln(1024)/ln(2) = 6.9315/0.6931 = 10, because 2¹⁰ = 1,024. Quick reference: log₂(2)=1, log₂(4)=2, log₂(8)=3, log₂(16)=4, log₂(32)=5, log₂(64)=6, log₂(128)=7, log₂(256)=8, log₂(512)=9, log₂(1024)=10.

    What is the change-of-base formula for logarithms?

    The change-of-base formula converts any logarithm to one that your calculator can handle: log_b(x) = ln(x) / ln(b) = log₁₀(x) / log₁₀(b). For instance, log₇(343) = ln(343)/ln(7) = 5.8377/1.9459 = 3, because 7³ = 343. This works for any valid base b (b > 0, b ≠ 1).

    What is the difference between log, log₁₀, and ln?

    All three are logarithms, but with different bases. log₁₀ (common logarithm) uses base 10 and is standard in chemistry (pH), seismology (Richter scale), and decibels. ln (natural logarithm) uses base e ≈ 2.71828 and appears in calculus, continuous growth models, and information theory. In US high-school math, 'log' without a subscript conventionally means log₁₀; in higher mathematics and many programming languages, 'log' often means ln — always check the context.

    Why can't the base equal 1?

    Because 1 raised to any power always equals 1: 1^y = 1 for all real y. This means there is no unique exponent y that satisfies 1^y = x for any x ≠ 1, making the logarithm undefined. Mathematically, the denominator ln(1) = 0 in the change-of-base formula, producing a division-by-zero error.

    Can the base be a fraction or decimal, like b = 0.5?

    Yes — any positive real number except 1 is a valid base. With b = 0.5, the logarithm is a decreasing function: log₀.₅(2) = −1 because 0.5^(−1) = 2. Fractional bases between 0 and 1 are less common but appear in radioactive decay formulas and certain probability models where quantities shrink over time.

    How is log₂ used in computer science?

    Base-2 logarithms are ubiquitous in CS. The number of bits needed to represent N distinct values is ⌈log₂(N)⌉ — encoding the 128 ASCII characters requires ⌈log₂(128)⌉ = 7 bits. The time complexity of binary search on a sorted list of N items is O(log₂ N) — searching 1 million records takes at most ⌈log₂(1,000,000)⌉ = 20 comparisons. Binary tree depth for N nodes is also ⌊log₂(N)⌋.

    How does the Richter scale use logarithms?

    The Richter magnitude M = log₁₀(A/A₀), where A is the maximum seismograph wave amplitude and A₀ is a reference value. Because it is a base-10 scale, each whole-number increase in magnitude corresponds to a 10× increase in amplitude and roughly a 31.6× increase in energy released (since energy ∝ amplitude^1.5, and 10^1.5 ≈ 31.6). A magnitude-8 quake releases about 31,600× more energy than a magnitude-6.

    What are the key logarithm rules (product, quotient, power)?

    The four essential identities (all require the same base b): Product: log_b(xy) = log_b(x) + log_b(y). Quotient: log_b(x/y) = log_b(x) − log_b(y). Power: log_b(xⁿ) = n · log_b(x). Change of base: log_b(x) = log_c(x) / log_c(b) for any valid base c. These rules underlie everything from slide-rule arithmetic to fast computation in early computers.

    How is the natural logarithm used in finance and continuous compounding?

    Under continuous compounding, the future value is FV = PV · e^(rt). Solving for time: t = ln(FV/PV) / r. To double your money (FV/PV = 2) at a continuous rate of 5%: t = ln(2)/0.05 = 0.6931/0.05 ≈ 13.86 years. This is more precise than the Rule of 72 (which gives 72/5 = 14.4 years) and is the basis for yield calculations in bonds and options pricing models such as Black-Scholes.

    What is log_b(1) for any base, and why?

    log_b(1) = 0 for every valid base b. This follows directly from the definition: b^0 = 1 for any b ≠ 0. Useful quick-check: if your calculator returns a non-zero value for log_b(1), there is an input error.

    Sources and references