Math & Basic

Logarithm Calculator

Logarithms for any base.

What is the Logarithm Calculator?

A logarithm answers how many times a base must be multiplied by itself to reach a given value (x). That is, log_b(x) = y means b^y = x. This tool supports common log (base 10), natural log (ln, base e), binary log (base 2), and any custom base.

How to use it

Enter a positive value for x, choose a base preset (10, e, 2) or type a custom base, then press Calculate. x must be greater than 0, and the base must be greater than 0 and not equal to 1.

Formula & reference

Change-of-base formula: log_b(x) = ln(x) / ln(b). Base 10 is the common log, base e (≈2.71828) is the natural log (ln), and base 2 is the binary log.

Sample values
ExpressionResult
log₁₀(100)2
ln(e)1
log₂(8)3
Why decibels, earthquake magnitude, and pH use a log scale

A decibel (dB) is defined as 10log₁₀(intensity ratio), so a 10x jump in sound intensity raises the level by exactly 10dB. A 100x jump gives 10log₁₀(100)=20dB, and a 1000x jump gives 10log₁₀(1000)=30dB — intensity grows exponentially while the decibel number grows in tidy, linear steps. Since audible sound intensity spans a range of trillions, dropping the log would make the raw numbers unmanageably large.

Earthquake magnitude works the same way: each whole step up in magnitude corresponds to roughly a 10x increase in ground amplitude. Magnitude 5 and magnitude 6 differ by only 1 on paper, but the actual shaking differs by a factor of 10. pH follows the identical pattern, defined as pH = −log₁₀([H⁺]); going from pH 4 to pH 7 (a difference of 3) means the hydrogen-ion concentration drops by 10³=1000x (check: −log₁₀(0.0001)=4). Without recognizing that "1 unit difference = 10x difference" on a log scale, it's easy to underestimate what a small change in decibels or magnitude actually means.

Choosing between log₂, log₁₀, and ln

Each base suits a different purpose. log₁₀ (common log) is intuitive for values that grow "by powers of 10," like digit counts, decibels, or pH. log₂ (binary log) fits processes that repeatedly halve, such as counting binary-search comparisons in a data structure (e.g. log₂(1024)=10 means finding one item among 1024 takes at most 10 comparisons). ln (natural log, base e) pairs most naturally with calculus for continuous-growth models — compound interest, population growth, radioactive decay — where the instantaneous rate of change is proportional to the current value. This calculator lets you switch between all three presets with one button, so you can compare them directly for your situation.

What is the change-of-base formula?
This tool uses the change-of-base formula log_b(x) = ln(x) / ln(b). Since JavaScript's Math.log() only provides the natural log (base e), dividing by ln(b) yields the logarithm for any desired base.
Why must x be greater than 0?
If x is zero or negative, the logarithm is not defined over the reals. Logarithm functions only produce real results for positive inputs, so x must be strictly greater than 0.
Why can't the base be 1?
If the base is 1, raising 1 to any power always gives 1, so log_1(x) is undefined (and has infinitely many solutions when x=1). The base must be greater than 0 and not equal to 1.
Why do decibels, earthquake magnitude, and pH use a log scale?
Decibels are defined so a 10x jump in sound intensity raises the level by exactly 10 (log10(10)=1 → 10dB), compressing the huge range the human ear can detect into manageable numbers. Earthquake magnitude and pH follow the same logic — each 1-unit difference corresponds to a 10x difference in the underlying physical quantity.
When should I use log2, log10, or ln?
Use log10 (common log) for values that scale in powers of 10, like digit counts, decibels, or pH. Use log2 (binary log) for computing processes that repeatedly halve, like search comparisons in a data structure. Use ln (natural log) for continuous-growth formulas — compound interest, radioactive decay — where the instantaneous rate of change matters.