Logarithm Calculator (Any Base)

A logarithm answers one question: what power do I raise this base to in order to get this number? Enter a value and a base and this calculator returns logb(x) using the change-of-base identity, alongside the three logarithms you meet most often — natural log, log base 2 and log base 10 — so you can read the same quantity in whichever scale your field uses. The antilog section reverses the operation: give it an exponent and it returns b raised to that power, which is how you undo a logarithm and recover the original number.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Value xThe number whose logarithm you want. It must be greater than zero — no real power of a positive base ever produces zero or a negative number.1000
Base bThe base of the logarithm. Use 10 for common logs, 2 for information and computing, or 2.718281828 for natural logs.10
Exponent y for the antilogThe antilog returns b raised to this power, which reverses a logarithm in the same base.3

It returns

  • log base b of x — The power that turns the base into x.
  • Natural log, ln x — Base e ≈ 2.718281828.
  • Common log, log₁₀ x
  • Binary log, log₂ x
  • Antilog: b raised to y — Recovers a number from its logarithm in base b.

The formula

logb(x)=lnxlnb
blogbx=x
logb(mn)=logbm+logbn

In plain text: log_b(x) = ln x / ln b

  • xThe value whose logarithm is wanted; must be greater than 0 (dimensionless)
  • bThe base; must be positive and not equal to 1 (dimensionless)
  • lnNatural logarithm, base e ≈ 2.718281828459045 (dimensionless)

The change-of-base identity works with any convenient base on the right-hand side — dividing two base-10 logs gives the same answer as dividing two natural logs.

Updated Category Exponents, Roots & Logarithms Verified against published test cases Reading time 10 min

A logarithm is an exponent

Every logarithm is the answer to a power question. "log10(1000)" asks: 10 raised to what gives 1,000? The answer is 3, so log10(1000) = 3. "log2(1024)" asks the same question with base 2, and the answer is 10. Nothing more is going on.

Because logarithms are exponents, they turn multiplication into addition. Multiplying two numbers adds their logarithms, dividing subtracts, and raising to a power multiplies the logarithm by that power. Before electronic calculators, this was the entire point: a table of logarithms and a ruler turned a long multiplication into a short addition, which is what slide rules did mechanically for three centuries.

The reason logarithms still matter is that they compress multiplicative structure into additive structure. Anything that grows or shrinks by repeated multiplication — compound interest, bacterial cultures, radioactive decay, sound intensity, earthquake energy, algorithm cost as data grows — becomes a straight line on a logarithmic scale. Equal distances along a log axis represent equal ratios, not equal differences, so a chart that looks like a wild exponential curve on a linear axis often reveals a simple constant rate on a log axis.

Two restrictions come with the definition. The value must be positive, because a positive base raised to any real power is always positive — there is no exponent that turns 10 into zero or into −5. And the base must be positive and not 1, because 1 raised to anything is still 1, so no exponent could ever get you anywhere else.

The three standard bases and the change-of-base formula

Three bases dominate, and the choice is about convenience, not mathematics.

Base 10, the common log, written log or log10. Its value is roughly the number of digits minus one, which makes it the natural language for orders of magnitude. It underpins pH, which is defined as −log10 of the hydrogen ion activity, and the decibel, defined as 10 log10 of a power ratio — or 20 log10 of an amplitude ratio, since power goes as amplitude squared.

Base e, the natural log, written ln, where e = 2.718281828…. It is the base at which the exponential function is its own derivative, so every continuous growth and decay model in physics, chemistry and finance uses it. Half-lives, continuously compounded returns and Newton's law of cooling are all written with ln.

Base 2, the binary log, written log2 or lb. It counts doublings, which makes it the unit of information — one bit is one binary decision — and the natural measure for divide-and-conquer algorithms, where log2(n) is the number of halvings needed to reduce a list of n items to one.

Any log can be converted to any other by a single division, which is the change-of-base identity: logb(x) = ln x ÷ ln b. The right-hand side can use any base you like, as long as both logs use the same one; base 10 works equally well. This is how a calculator with only ln and log10 buttons produces a logarithm in base 7, and it is what this calculator does internally.

The identity also tells you that all logarithms are proportional to one another. log2(x) is always ln(x) ÷ 0.6931, which is 1.4427 times ln(x), for every x. So the shape of a logarithmic relationship never depends on the base — only the scale does.

Worked example: log base 7 of 200, by change of base

Suppose you need log7(200) and have only natural logs available.

  1. Take the natural log of the value. ln 200 = 5.298317367.
  2. Take the natural log of the base. ln 7 = 1.945910149.
  3. Divide. 5.298317367 ÷ 1.945910149 = 2.72281.
  4. Check by antilog. 72.72281 = 200.0. The check is the definition applied backwards, and it is worth doing whenever the answer is not a whole number.
  5. Sanity-check the bracket. 72 = 49 and 73 = 343, so the answer must lie between 2 and 3, and closer to 3 since 200 is nearer 343 than 49 on a multiplicative scale. 2.72 fits.

The same answer through base 10. log10(200) = 2.301030 and log10(7) = 0.845098. Dividing: 2.301030 ÷ 0.845098 = 2.72281. Identical, as the identity promises, because the constant relating the two log scales cancels in the ratio.

Using the log laws instead. 200 = 2 × 100, so log10(200) = log10(2) + log10(100) = 0.30103 + 2 = 2.30103, which is where the number in step 1 of the alternative route comes from. That decomposition — split off the powers of ten, look up the rest — is exactly how printed log tables were used, and it still makes mental estimates easy: any number between 100 and 1,000 has a base-10 log between 2 and 3.

What the number is telling you

Read a logarithm as a count of multiplications. log2(1000) ≈ 9.97 means it takes just under ten doublings to get from 1 to 1,000. log10(1000) = 3 means three tenfold steps. The whole part tells you the order of magnitude; the fractional part locates you between two consecutive powers of the base.

The sign is a comparison with 1. In any base greater than 1, values above 1 have positive logarithms, a value of exactly 1 has a logarithm of zero in every base, and values between 0 and 1 have negative logarithms. That is why pH is defined with a minus sign in front: hydrogen ion concentrations in water are small numbers like 10−7, and flipping the sign turns an awkward −7 into a friendly 7.

Differences on a log scale are ratios on the original scale. A gap of 1 in log10 means a factor of 10; a gap of 0.301 means a factor of 2. This is what makes log axes the right choice for data spanning several orders of magnitude, and it is why an earthquake one point higher on a base-10 magnitude scale represents about ten times the ground-motion amplitude.

Growth rates come out as slopes. If a quantity multiplies by a constant factor each period, its logarithm increases by a constant amount each period, so plotting the log against time gives a straight line whose slope is the growth rate. Fitting that line is more robust than fitting a curve, which is why log plots are standard for anything exponential.

Logarithms of common values in three bases

The same value read in three scales. Every row satisfies log2(x) = ln(x) ÷ 0.693147 = log10(x) ÷ 0.301030. Values are rounded to five decimal places.
xlog10 xln xlog2 x
10.000000.000000.00000
20.301030.693151.00000
30.477121.098611.58496
50.698971.609442.32193
101.000002.302593.32193
1002.000004.605176.64386
1,0003.000006.907769.96578
1,000,0006.0000013.8155119.93157

Two figures are worth memorising: log₁₀2 = 0.30103, so a doubling is about three tenths of a decade; and log₂10 = 3.32193, so ten doublings is a bit more than three decades — which is why 2¹⁰ = 1,024 sits so close to 1,000.

Mistakes that logarithms invite

  • Splitting the log of a sum. log(a + b) has no expansion. Only products, quotients and powers decompose: log(ab) = log a + log b. Writing log(a + b) = log a + log b is wrong for every pair of values except contrived ones.
  • Confusing log(x²) with (log x)². The first is 2 log x; the second is the square of the logarithm, an entirely different quantity.
  • Taking the log of a negative number or zero. Neither exists in the real numbers. If your data contains zeros, a log transform will drop them silently unless you handle them deliberately.
  • Assuming 'log' means base 10. It does in engineering and chemistry, but in pure mathematics and in most programming languages an unqualified log means the natural log, and in computer science it often means base 2. Check before trusting a formula.
  • Averaging logged values and reporting the mean as if it were on the original scale. Averaging logs and converting back gives the geometric mean, not the arithmetic mean, and the two differ whenever the data varies at all.
  • Reading a log-scale chart as if the gridlines were equally spaced in value. They are equally spaced in ratio, so the visual midpoint between 1 and 100 is 10, not 50.

Logarithms next to the tools that undo them

The exact inverse of a logarithm is a power, so the exponent calculator is the other half of this page: whatever logb(x) returns, raising b to it gives x back. Use the exponent tool when you know the rate and want the result, and this one when you know the result and want the rate or the number of periods.

Half of what base-10 logs are for is orders of magnitude, which is also what scientific notation records. The exponent in 6.022 × 1023 is the whole part of the base-10 logarithm, and the scientific notation calculator converts between the forms, including engineering notation in multiples of three. How many of those digits are meaningful is a separate question, handled by the significant figures calculator.

Roots are fractional powers, so they can be computed with logs: the nth root of x is the antilog of (log x) ÷ n. For the commonest case, the square root calculator is more direct and gives exact answers for perfect squares.

Where logarithms turn up in growth problems, the practical question is usually how many periods a compounding process needs, which is a log divided by a log: the percentage increase and decrease calculator handles the forward direction, and taking logs of both sides inverts it. In number theory, the count of digits of a large number is one more than the whole part of its base-10 logarithm, which pairs naturally with the prime factorization calculator and the number base conversion calculator, where log2 gives the bit length directly.

Frequently asked questions

How do I calculate a logarithm in a base my calculator doesn't have?

Use the change-of-base formula: logb(x) = ln x ÷ ln b. For log7(200): ln 200 = 5.29832 and ln 7 = 1.94591, so the answer is 2.72281. You can use base-10 logs on both top and bottom instead and get the identical result, because the conversion constant cancels in the ratio.

What is the difference between log and ln?

ln is the logarithm to base e ≈ 2.71828; log usually means base 10 in engineering, chemistry and on calculator keypads. They are proportional: ln x = 2.302585 × log10 x. The ambiguity is real — in pure mathematics and in most programming languages, an unqualified log means the natural logarithm, so always check which convention a formula assumes.

Why can't you take the logarithm of a negative number?

Because no real exponent turns a positive base into a negative result. 10 raised to any real power — positive, negative, fractional — is always positive, so there is no answer to "10 to the what gives −5". Complex analysis extends logarithms to negative numbers using imaginary parts, but the extension is multi-valued and is not what a scientific calculator reports.

What is an antilog?

The antilog is the inverse operation: antilogb(y) = by. If log10(1000) = 3, then the antilog base 10 of 3 is 1,000. It is how you recover a concentration from a pH reading (concentration = 10−pH) or a sound pressure ratio from a decibel figure. On older calculators it was labelled 10x or ex.

What is log base 2 used for?

Counting doublings and halvings. In computing it gives the number of bits needed to represent a value and the depth of a binary search — log2(1,000,000) ≈ 19.93, so about twenty comparisons locate any item in a million-item sorted list. In information theory it is the unit of entropy, one bit per binary choice. In music, one octave is a doubling of frequency, so pitch intervals are base-2 logarithms.

Why is log(1) always zero?

Because any base raised to the power zero is 1. The question "b to the what gives 1" always has the answer 0, whatever b is, so logb(1) = 0 in every valid base. It follows that values above 1 have positive logarithms and values between 0 and 1 have negative ones, for any base greater than 1.

How do logarithms turn multiplication into addition?

Because logarithms are exponents, and multiplying powers of the same base adds the exponents. Since 102 × 103 = 105, it follows that log(100 × 1000) = log 100 + log 1000. That identity is what made log tables and slide rules work, and it is still the reason log scales linearise anything that grows by repeated multiplication.

How many digits does a large number have?

One more than the whole part of its base-10 logarithm. log10(1000) = 3 exactly, and 1,000 has four digits. For 2100: 100 × log10(2) = 30.103, so it has 31 digits. This works for any number too large to display, which is one of the practical reasons to compute a logarithm rather than the number itself.

References