Logarithm Calculator — Any Base
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.
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
- Find log₂(1024): x = 1024, b = 2
- log₂(1024) = ln(1024) / ln(2) = 6.9315 / 0.6931 = 10
- Verify: 2¹⁰ = 1,024 ✓
How it works
3 min readHow 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:
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.
| x | log₂(x) | log₃(x) | log₅(x) | log₁₀(x) | ln(x) [base e] |
|---|---|---|---|---|---|
| 1 | 0 | 0 | 0 | 0 | 0 |
| 2 | 1 | 0.6309 | 0.4307 | 0.3010 | 0.6931 |
| 4 | 2 | 1.2619 | 0.8614 | 0.6021 | 1.3863 |
| 8 | 3 | 1.8928 | 1.2920 | 0.9031 | 2.0794 |
| 10 | 3.3219 | 2.0959 | 1.4307 | 1 | 2.3026 |
| 16 | 4 | 2.5237 | 1.7227 | 1.2041 | 2.7726 |
| 32 | 5 | 3.1546 | 2.1534 | 1.5051 | 3.4657 |
| 100 | 6.6439 | 4.1918 | 2.8614 | 2 | 4.6052 |
| 256 | 8 | 5.0474 | 3.4454 | 2.4082 | 5.5452 |
| 1,000 | 9.9658 | 6.2877 | 4.2920 | 3 | 6.9078 |
| 1,024 | 10 | 6.2995 | 4.3008 | 3.0103 | 6.9315 |
| 1,000,000 | 19.9316 | 12.5754 | 8.5840 | 6 | 13.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.9A 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 bitsA 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 yearsThe 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
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.