Logarithm Calculator
Compute logarithms in any base including natural log.
About the Logarithm Calculator
The logarithm calculator computes the logarithm of any positive number in any base. A logarithm answers the question "to what power must I raise the base to get this number?" The base-10 logarithm of 1000 is 3, because 10 raised to the power 3 equals 1000. The natural logarithm (base e) of 20 is approximately 3, because e raised to the power 3 is approximately 20.
Logarithms appear throughout science and engineering. The pH scale in chemistry is a base-10 logarithm of hydrogen ion concentration. The decibel scale in acoustics is a base-10 logarithm of sound intensity. The Richter scale for earthquakes is a base-10 logarithm of seismic wave amplitude. In computer science, binary logarithms (base 2) measure the depth of binary trees and the number of bits needed to represent a value.
This calculator reports the logarithm in your chosen base, along with the natural logarithm (base e), the common logarithm (base 10), and the binary logarithm (base 2) for reference. It also displays the inverse check (the base raised to the result), which should equal your original input if the calculation is correct.
How It Works
The logarithm in any base b is computed using the change-of-base formula, which expresses it in terms of natural logarithms:
log_b(x) = ln(x) / ln(b)
This formula works because logarithms in different bases are proportional to each other. The constant of proportionality is 1 / ln(b), so converting from natural log to any other base is a simple division. JavaScript's Math.log computes the natural logarithm, and dividing by Math.log(base) gives the logarithm in any base.
The natural logarithm ln(x) uses e (approximately 2.71828) as its base. The common logarithm log10(x) uses 10 as its base and is the default on many calculators. The binary logarithm log2(x) uses 2 as its base and is central to information theory and computer science.
The inverse of a logarithm is an exponentiation: if y = log_b(x), then b^y = x. The calculator verifies this by computing b^result, which should equal your original input x within floating-point precision. This is the same relationship that links logarithms and exponentials as inverse functions.
Worked Examples
Using the default inputs x = 1000 and base = 10, the calculator computes log10(1000) = ln(1000) / ln(10) = 6.9078 / 2.3026 = 3. The inverse check confirms that 10^3 = 1000. The natural logarithm of 1000 is approximately 6.9078, and the binary logarithm is approximately 9.9658.
For a natural logarithm, set x = 20 and base = e (approximately 2.71828). The result is ln(20) = 2.9957. The inverse check confirms that e^2.9957 is approximately 20. Natural logarithms are the default in higher mathematics and calculus because they have the simplest derivative (d/dx of ln(x) is 1/x).
For a binary logarithm, set x = 256 and base = 2. The result is log2(256) = 8, because 2^8 = 256. This is why 256 is a round number in computing: it is a power of 2, and binary logarithms of powers of 2 are always integers.
When to Use This Tool
Use the logarithm calculator whenever you need to solve exponential equations or work with logarithmic scales:
- Computing pH in chemistry (pH = -log10 of hydrogen ion concentration).
- Calculating decibel levels in acoustics (dB = 10 * log10 of intensity ratio).
- Measuring earthquake magnitudes on the Richter scale.
- Determining the number of bits needed to represent a value (log2).
- Solving for time in exponential growth or decay models.
- Working with signal-to-noise ratios in engineering.
- Computing the doubling time of an investment or population.
Limitations & Disclaimer
The logarithm is defined only for positive real inputs. The base must be a positive number other than 1. Results are subject to floating-point precision limits, and very large or very small arguments may lose accuracy. This calculator does not compute complex logarithms (which extend the function to negative and complex inputs). For complex analysis, use a dedicated mathematical software package. See our disclaimer for full details.
Frequently Asked Questions
What is the change-of-base formula?
It states that log_b(x) equals ln(x) divided by ln(b), where ln is the natural logarithm (base e). This formula lets you compute a logarithm in any base using the natural logarithm function, which is what most programming languages and calculators provide natively.
What is the natural logarithm?
The natural logarithm, written ln(x) or log_e(x), uses e (approximately 2.71828) as its base. It is the default logarithm in higher mathematics and calculus because its derivative is the simplest possible (1/x), which makes it appear naturally in differential equations describing growth and decay.
Why must x be positive?
Because the logarithm is the inverse of exponentiation, and any positive base raised to a real power gives a positive result. There is no real power to which you can raise a positive base to get zero or a negative number, so the logarithm is undefined for non-positive inputs.
Why can the base not be 1?
Because 1 raised to any power is always 1, so the logarithm base 1 would have to assign infinitely many different powers to the single value 1, which is impossible. The base must be a positive number other than 1.
How are logarithms used in the pH scale?
The pH of a solution is defined as minus the base-10 logarithm of its hydrogen ion concentration: pH = -log10[H+]. A solution with concentration 10^-7 has pH 7 (neutral), and a solution with concentration 10^-1 has pH 1 (strongly acidic). The logarithmic scale compresses a wide range of concentrations into a 0-14 range.
What is the relationship between logarithms and exponentials?
They are inverse functions. If y = log_b(x), then b^y = x. The calculator verifies this by displaying the inverse check, which raises the base to the computed result and confirms it equals the original input within floating-point precision.
Last updated: July 21, 2026 · Author: HT99 Tools Editorial Team · Reviewed by: HT99 Tools Editorial Team