Logarithm Calculator
Compute logarithms with different bases. Find the natural logarithm (ln), common logarithm (log base 10), or specify any custom base. Essential for scientific, engineering, and mathematical calculations.
Logarithms are the inverse of exponentials. If b^x = y, then log_b(y) = x. They answer the question: "To what power must I raise the base to get this number?" If 10² = 100, then log₁₀(100) = 2. If 2³ = 8, then log₂(8) = 3. This simple inverse relationship makes logarithms incredibly useful for any quantity that spans many orders of magnitude.
Three logarithms appear most frequently: - **Common logarithm (log)**: base 10. Used in engineering and scientific notation. - **Natural logarithm (ln)**: base e ≈ 2.71828. Used in calculus and physics. - **Binary logarithm (log₂)**: base 2. Used in computer science.
Logarithms tame exponential growth into manageable numbers. The Richter earthquake scale uses log₁₀ — a magnitude 7 earthquake releases 10× more energy than magnitude 6, 100× more than magnitude 5. Sound pressure (decibels) uses log₁₀ × 20. The pH scale is log₁₀ of hydrogen ion concentration. Information measured in bits is log₂.
Key properties make logarithms powerful for arithmetic and analysis: - log(a × b) = log(a) + log(b) — multiplication becomes addition. - log(a/b) = log(a) − log(b) — division becomes subtraction. - log(a^n) = n × log(a) — exponents become multiplication.
Before electronic calculators, slide rules used logarithms to perform multiplication and division mechanically. Astronomers and scientists relied on log tables for centuries to perform calculations that would otherwise have taken years.
Common applications: scientific notation, pH chemistry, sound (decibels), earthquakes (Richter), information theory (bits), finance (continuous compounding), and any analysis with wide-range values.
Inputs
Only used when Custom Base is selected
Results
Result
2
Log Base 10
2
Natural Log (ln)
4.605170186
Log Base 2
6.6438561898
Formula
How to use this calculator
- Enter a positive number.
- Choose base: log (base 10), ln (base e), or custom.
- For custom base: enter the base (must be positive, not 1).
- Calculator returns the logarithm value.
- Verify: base^result should equal input number.
- For ratios: log of ratio = difference of logs.
Worked examples
Earthquake comparison
**Scenario:** Compare magnitude 7.0 vs magnitude 5.0 earthquakes. Energy ratio? **Calculation:** Difference: 7 - 5 = 2 on Richter scale. Energy ratio: 32² ≈ 1000× (each magnitude step is ~32× more energy). Amplitude ratio: 10² = 100×. **Result:** Magnitude 7 releases ~1000× more energy than magnitude 5 — and ~100× more shaking amplitude. Common misconception: M7 vs M5 is "twice as bad"; actually it's ~1000× more energy. Logarithmic scale compresses huge differences into small number increments.
Binary search complexity
**Scenario:** Binary search on sorted list of 1 million items. How many comparisons needed? **Calculation:** log₂(1,000,000) ≈ 20. **Result:** ~20 comparisons. Each step halves search space. For 1 billion items: log₂(10⁹) ≈ 30 comparisons. Why binary search is so efficient: O(log n) growth means even huge data sets are quickly searched.
pH calculation
**Scenario:** Solution has [H⁺] = 5 × 10⁻⁹ M. Calculate pH. **Calculation:** pH = -log₁₀(5 × 10⁻⁹) = -log₁₀(5) - log₁₀(10⁻⁹) = -0.699 - (-9) = 8.30. **Result:** pH ≈ 8.3 (slightly basic). For reference: pH 7 = neutral; pH < 7 acidic; pH > 7 basic. Pure water: pH 7. Stomach acid: pH ~1.5. Blood: pH ~7.4. Bleach: pH ~12.
When to use this calculator
**Use logarithms for:**
- **Wide-range data**: scientific notation, magnitudes. - **Multiplication into addition**: easier mental math for products. - **Exponential analysis**: doubling times, decay rates. - **Sound (decibels)**: sound pressure measurements. - **pH (chemistry)**: hydrogen ion concentration. - **Information theory**: bits, entropy. - **Computer science**: algorithm analysis (O(log n)). - **Astronomy**: stellar magnitudes.
**Choosing base:**
- **Base 10 (log)**: scientific notation, engineering. - **Base e (ln)**: calculus, physics, continuous growth. - **Base 2 (log₂)**: computer science, information theory. - **Custom**: specific applications.
Use whichever makes the formula simplest in context.
**Common log values to memorize:**
log₁₀: - log 1 = 0 - log 10 = 1 - log 100 = 2 - log 1000 = 3 - log 2 ≈ 0.301 - log 3 ≈ 0.477 - log 5 ≈ 0.699 - log 7 ≈ 0.845
These let you quickly estimate logs without calculator.
**Computing arbitrary base logarithm:**
log_a(x) = log(x) / log(a) = ln(x) / ln(a)
Change of base formula uses common or natural log.
**Real-world log scales:**
- **Richter (earthquakes)**: each unit = 10× amplitude. - **Decibel (sound)**: each 10 dB = 10× power. - **pH (acidity)**: each unit = 10× [H⁺]. - **Stellar magnitude**: each 5 = 100× brightness. - **Octave (music)**: doubling of frequency. - **F-stop (photography)**: each stop = 2× light.
**Inverse: exponentials:**
If log_b(x) = y, then x = b^y.
Logarithms and exponents are inverse functions. Together: x = b^(log_b(x)) and y = log_b(b^y).
**Common applications:**
- **Engineering**: signal processing, control systems, dB calculations. - **Chemistry**: equilibrium, kinetics, pH. - **Biology**: population growth, enzyme kinetics. - **Economics**: continuous compounding. - **Statistics**: log-normal distribution. - **Computer science**: algorithmic analysis, data structures. - **Astronomy**: magnitudes, photometry. - **Acoustics**: sound levels.
**Software:**
- **Calculators**: log button (base 10), ln button (natural). - **Spreadsheets**: LOG10, LN, LOG functions. - **Python**: math.log, math.log10, math.log2. - **JavaScript**: Math.log, Math.log10, Math.log2. - **R/MATLAB**: log() is natural; log10() is common.
**Why logarithms changed math:**
Before computers, multiplying large numbers was tedious. With log tables: 1. Look up logs of both numbers. 2. Add them. 3. Look up antilogarithm.
This converted hours of arithmetic into seconds. Slide rules embodied this principle physically. Used for centuries by astronomers, engineers, navigators.
**Computational complexity:**
| Algorithm | Complexity | |---|---| | Linear search | O(n) | | Binary search | O(log n) | | Sort (best) | O(n log n) | | Tree operations | O(log n) |
Logarithmic is just slightly worse than constant — extremely fast for large inputs.
**Pitfalls:**
- **Log of zero or negative**: undefined in real numbers. - **Implicit base**: "log" can mean 10 (basic math) or e (advanced math). - **Order of operations**: log(a) + log(b) = log(ab), not log(a+b). - **Base 1**: undefined (1^x = 1, can't reach other numbers). - **Floating-point precision**: very small numbers have precision issues. - **Domain**: input must be positive.
Common mistakes to avoid
- Confusing log of sum with sum of logs (log(a+b) ≠ log(a) + log(b)).
- Taking log of zero or negative (undefined in real numbers).
- Confusing common log (base 10) with natural log (base e).
- Implicit base assumption (depends on context).
- Forgetting properties: log(a*b) = log(a) + log(b), log(a/b) = log(a) - log(b).
- Wrong base in change of base formula.
- For decibels: factor 20 (voltage) vs 10 (power).
- For programming: log() function meaning varies by language.