Excel calculates logarithms with three built-in functions: LN(x) returns the natural log in base e (about 2.71828), LOG10(x) returns the common log in base 10, and LOG(x, base) returns the log of x in any base you specify. A logarithm answers one question: what power do you raise a base to in order to get a given number? The argument x must be greater than 0 because no real power of a positive base ever produces 0 or a negative number, and the base must also be greater than 0 and cannot equal 1 — a base of 1 would make ln(b) = 0 and force a division by zero in the change of base formula. Type =LN(8) into a cell and Excel returns about 2.0794; type =LOG10(8) and you get roughly 0.9031; type =LOG(8, 2) and you get exactly 3, because 2³ = 8. For quick spot-checking, formula-free work, or uncommon bases like log5 or log7, a browser-based Logarithm Calculator gives the same answers live as you type and shows a 2^exponent-style explanation that turns the abstract exponent into a concrete equality you can read off the page.

how to calculate logarithm in excel
how to calculate logarithm in excel

Excel's Three Built-In Logarithm Functions

Excel ships with three logarithm functions and they cover almost every case you will meet at a desk. The table below compares what each one does, the syntax you type into a cell, and a sample result for x = 8 so you can see the answers side by side.

Function Syntax Base Example for x = 8 Common use
LN =LN(x) e ≈ 2.71828 =LN(8) ≈ 2.0794 Growth, half-life, calculus, continuous compounding
LOG10 =LOG10(x) 10 =LOG10(8) ≈ 0.9031 pH, decibels, Richter scale, stellar magnitudes
LOG =LOG(x, base) Any base > 0, ≠ 1 =LOG(8, 2) = 3 Information entropy, O(log n) running times, custom bases

Each function returns a #NUM! error if x is 0 or negative, and the LOG function returns #NUM! if the base is 0, negative, or 1. Excel's behaviour here matches the mathematical definition — the Logarithm Calculator enforces the same input rules and shows a clear "undefined" message for the same invalid combinations. If your dataset contains zeros or blanks, wrap the formula in IFERROR or filter them out before applying any of the three functions, otherwise a single bad cell can poison an entire column of results.

Calculate Logarithm in Excel Step by Step

The most reliable workflow is to start with a known value, type the right function, and let Excel return the exponent. Follow these steps to compute a logarithm in Excel for any single cell, then drag the formula down across a column of values.

  1. Click the cell where you want the answer and type the equals sign to start a formula.
  2. Type LN(, LOG10(, or LOG( depending on which logarithm you need.
  3. Click the cell that contains your argument — for example A2 — or type a positive number directly. The argument must be greater than 0.
  4. If you used LOG, add a comma and type the base — for example 2 for binary log, 5 for log5, or 10 for log10. The base must be greater than 0 and not equal to 1. You can also reference another cell such as B2 for the base.
  5. Close the parenthesis and press Enter. Excel displays the result immediately and updates it whenever the argument or base cell changes.

For example, if A2 holds the number 1000 and you type =LOG10(A2) in cell B2, Excel returns 3 because 10³ = 1000. Drag the fill handle down to copy the formula across a column of values and Excel recomputes each row automatically. To turn the result back into the original number, wrap the formula in 10^B2 for common logs, EXP(B2) for natural logs, or base^B2 for any other base — this is the inverse operation and is the fastest way to confirm that your log formula is correct before you move on.

Logarithm in Any Base Using the Change of Base Formula

Excel's LOG function already accepts any base, so for most users that is enough. But there are two situations where the underlying change of base formula is useful: when you want to see the math explicitly so you can explain the calculation to a colleague, and when you are working in an older spreadsheet or a different tool that lacks the two-argument form of LOG. The identity is:

log_b(x) = ln(x) ÷ ln(b)

In Excel you can type this directly:

= LN(A2) / LN(B2)

where A2 holds x and B2 holds the base. For example, log5(25) becomes =LN(25)/LN(5), which Excel evaluates to exactly 2 because 5² = 25. The Logarithm Calculator uses this same identity under the hood for any base you enter, so the browser result always matches what =LN(x)/LN(b) produces in Excel. If you ever need a base that is not 2, 10, or e — say log7(49) for a niche statistics problem — typing =LN(49)/LN(7) into Excel returns 2 just as quickly, and you avoid having to remember which logarithm button to press on a handheld device.

Verify Excel Results With a Browser Calculator

When you are working through a long column of data, formula typos and accidental cell references are easy to miss. A quick way to sanity-check any Excel logarithm is to open the Logarithm Calculator in a separate tab and compare. Type the same argument and base into the calculator and the result appears as you type, alongside ln(x), log10(x), and log2(x) for the same number, so you can check all four results in a single glance. Everything runs locally in your browser — nothing is sent to a server — so the calculator works offline and stays private even when you are reviewing sensitive financial or research data.

For results that are whole numbers, the calculator prints an equals sign — log2(8) = 3 — so there is no ambiguity about whether the trailing decimals are real. For genuinely irrational results like log10(7) ≈ 0.845098, it shows an approximately-equal sign and keeps the full decimal detail so the answer stays honest. Tiny floating-point noise — for example 3.0000000000000004 instead of 3 — is trimmed to twelve significant figures, so you never see noise masquerading as a meaningful digit. This is the same precision your eye expects from a hand calculation, and it is enough to clean stray binary noise back to an integer without ever hiding a real fractional result.

Common Errors and Input Rules

Excel and the Logarithm Calculator enforce the same mathematical limits, and recognising them saves time on data that looks plausible but produces #NUM! errors.

  • x must be greater than 0. A positive base raised to any real power stays positive, so no exponent can ever produce 0 or a negative number — the logarithm simply does not exist there.
  • The base must be greater than 0 and cannot equal 1. A base of 1 would make ln(b) = 0 and force a division by zero in the change of base formula, and every power of 1 is just 1.
  • Nested LN(0) or LN of an empty cell returns #DIV/0! in Excel because ln(0) is undefined. Replace 0 with a tiny positive fallback, or filter the cell out of the range before applying the formula.
  • LOG(x, base) returns #NUM! when either argument violates the rules above. Switch to =LN(x)/LN(base) only after both cells hold valid positive values.

When in doubt, paste the suspect value and base into the Logarithm Calculator first — if it returns a defined number, you know the formula in Excel will work, and if it shows an undefined message you have caught the bad input before it propagated through the column. This two-step habit — browser check, then spreadsheet formula — is the fastest way to keep a model clean when the source data has gaps, negatives, or stray text values that Excel would otherwise surface as #VALUE! errors in your summary table.