Logarithm Calculator (log base b of x)
Calculate log base b of x for any positive value and base, including common (base 10), natural (base e), and binary (base 2) logs, with steps.
What a logarithm means
A logarithm answers a "what power?" question. means: raising the base to the power gives . It is written the other way in exponent form:
For example, because — you have to multiply by itself times to reach . A logarithm and an exponent describe the exact same relationship between , , and ; the logarithm just solves for the exponent instead of the result.
The logarithm is the inverse of exponentiation
Exponentiation and logarithms undo each other, the same way addition/subtraction and multiplication/division do:
| Question | Operation | Example |
|---|---|---|
| What is raised to the ? | Exponentiation: solve for in | |
| What power gives ? | Logarithm: solve for in |
Because they are inverses, raising the base to a logarithm always returns the original value: . This calculator's "The defining identity" section shows this plugged-in check for every result.
Three named logarithms
Any positive base (other than 1) is valid, but three bases show up so often they have their own names:
| Name | Base | Notation | Common use |
|---|---|---|---|
| Common logarithm | or just | pH scale, decibels, orders of magnitude | |
| Natural logarithm | calculus, continuous growth/decay | ||
| Binary logarithm | computer science, bits, binary search |
Type e in the base field for the natural logarithm — this calculator treats the literal letter e as Euler's number, computed to full precision.
Why x and the base have restrictions
A logarithm is only defined when and the base satisfies and :
- is invalid. A positive base raised to any real power always stays positive — there is no real with when .
- is invalid. Raising a negative base to a non-integer power (which almost every logarithm result is) is not a real number.
- is invalid. for every , so has no single answer — it is left undefined rather than guessed at.
This calculator reports any of those combinations as out of range instead of returning a misleading number.
Exact results vs. decimal approximations
When is a perfect power of the base — like or — the result is a whole number, computed exactly. Most inputs are not perfect powers, so the result is an irrational decimal, which this calculator rounds to 6 decimal places: , since no whole power of 10 lands exactly on 8.
Example 1 (exact, binary log): , since .
Example 2 (exact, common log): , since .
Example 3 (exact, natural log): , since .
Example 4 (decimal approximation): , since .
Where logarithms show up
Logarithms compress huge ranges of numbers into manageable scales — the Richter scale, the decibel scale, and pH are all logarithmic for exactly this reason. In finance, the natural log turns compound growth rates into something you can add and subtract. In computer science, binary logarithms measure how many times a problem can be split in half, which is why sorting and searching algorithms are described in terms of . For the reverse question — solving an equation for an unknown exponent — see the related exponent calculators; for whole-number and fractional powers themselves, see the Exponents calculator and the Fractional Exponents calculator.
Frequently asked questions
- What is a logarithm?
- A logarithm answers the question "what power do I raise the base to, to get this number?" means the same thing as — the logarithm and the exponent are inverse operations. For example because .
- What is the difference between log and ln?
- (often written just ) is the common logarithm, base 10. is the natural logarithm, base . Both are logarithms — they only differ in which base is used. This calculator computes either (and any other positive base) depending on what you enter in the base field.
- Why can't the base be 1, and why can't x be 0 or negative?
- A logarithm is only defined for and a base with . If , no real power of a positive base ever produces (a positive base to any real power stays positive). If , then for every , so could be any number — the equation has no unique answer, so it is left undefined.
- What is a common logarithm?
- A common logarithm is a logarithm with base 10: , often written without the subscript as just . Before calculators, common logs were used to turn multiplication into addition (via log tables) and they still appear throughout science, e.g. the pH scale and the decibel scale are both base-10 logarithmic scales.
- What is a natural logarithm?
- A natural logarithm has base (Euler's number, approximately 2.718281828), written . It shows up naturally in calculus, continuous compound growth and decay, and many formulas in physics and finance, because is its own derivative.
- What is a binary logarithm used for?
- A binary logarithm has base 2, written . It answers "how many times do I need to double 1 to reach x?" and shows up constantly in computer science — the number of bits needed to represent a number, and the number of steps in a binary search or a balanced binary tree, both grow like .
- How is a logarithm the inverse of an exponent?
- Exponentiation and logarithms undo each other, the same way multiplication and division do. and describe the same three numbers (, , ) — exponentiation solves for given and , while the logarithm solves for given and . Raising the base to the log always gives back the original number: .
- Why is a logarithm sometimes a rounded decimal instead of a whole number?
- Most values of x are not exact whole-number powers of the base, so is usually an irrational decimal. because no whole number of 10s multiplies together to give exactly 8 — this calculator shows the decimal approximation rounded to 6 places. When x IS a perfect power of the base (like ), the result is exact.