Logarithm Calculator — Log Base N of X

Result

Formula

Related Values

How Logarithms Work

A logarithm is the inverse operation of exponentiation, answering the question: to what power must a given base be raised to produce a specific number? Formally, log_b(x) = y means b^y = x. The concept was invented independently by John Napier (1614) and Jost Burgi (1620) to simplify astronomical and navigational calculations. According to the Mathematical Association of America, the invention of logarithms effectively doubled the lifetime of astronomers by halving the time they spent on tedious multiplication and division. Today, logarithms are foundational across mathematics, physics, engineering, computer science, finance, and data science.

This calculator computes logarithms for any positive number using common log (base 10), natural log (base e = 2.71828...), binary log (base 2), or any custom base. All computation happens in your browser using the JavaScript Math.log function and the change-of-base formula. The three standard bases each serve distinct domains: base 10 powers the Richter earthquake scale, decibel measurements, and pH chemistry; base e underpins calculus, continuous growth models, and statistical distributions; and base 2 is essential for algorithm analysis, information theory, and binary computing.

The Logarithm Formula and Change of Base

The fundamental definition: log_b(x) = y means b^y = x, where b is the base (must be positive and not equal to 1), x is the argument (must be positive), and y is the result. The change of base formula allows you to compute logarithms of any base using only natural log (ln) or common log (log): log_b(x) = ln(x) / ln(b) = log(x) / log(b). This is how calculators and programming languages compute arbitrary-base logarithms internally.

Worked example: Find log_5(125). Using the definition: 5^y = 125. Since 5^3 = 125, log_5(125) = 3. Using the change of base formula: log_5(125) = ln(125) / ln(5) = 4.8283 / 1.6094 = 3.0000. Both methods yield the same result. For non-integer answers: log_3(20) = ln(20) / ln(3) = 2.9957 / 1.0986 = 2.7268, meaning 3^2.7268 = 20.

Key Terms You Should Know

Common Logarithm Values Reference Table

The following table provides reference values for the three standard logarithm bases. These values appear frequently in science, engineering, and computer science problems.

xlog_10(x)ln(x)log_2(x)Significance
1000log of 1 is always 0 for any base
20.30100.693111 bit of information
e (2.718)0.434311.4427Euler's number; ln(e) = 1
1012.30263.32191 order of magnitude
10024.60526.64392 orders of magnitude
1,00036.90789.9658~10 bits to represent
1,000,000613.815519.9316~20 bits; binary search needs 20 steps

Practical Examples

Example 1 — pH calculation: A solution has a hydrogen ion concentration [H+] of 0.001 mol/L. The pH = -log_10(0.001) = -log_10(10^-3) = -(-3) = 3. This makes it an acidic solution. Each unit decrease in pH represents a 10x increase in acidity. Use our scientific notation calculator for handling very small or large numbers.

Example 2 — Earthquake magnitude comparison: A magnitude 7.0 earthquake releases how much more energy than a magnitude 5.0? The Richter scale is logarithmic: each whole number increase corresponds to a 10x increase in measured amplitude and approximately 31.6x increase in energy. So a 7.0 quake releases 31.6^2 = approximately 1,000 times more energy than a 5.0 quake.

Example 3 — Binary search efficiency: How many comparisons does binary search need for a sorted array of 1 million elements? log_2(1,000,000) = 19.93, so at most 20 comparisons are needed. This is why binary search is O(log n) — even for a billion elements, only about 30 comparisons are required. Compare this to percentage calculations where linear scaling applies.

Tips and Strategies for Working with Logarithms

Real-World Logarithmic Scales

Logarithmic scales are used throughout science and engineering to handle quantities that vary over enormous ranges. The decibel scale measures sound intensity: 0 dB is the threshold of hearing, 60 dB is normal conversation, 120 dB is a rock concert, and 140 dB causes pain — each 10 dB increase represents a 10x increase in sound intensity. The pH scale measures acidity: each unit change represents a 10x change in hydrogen ion concentration, so pH 3 is 10,000 times more acidic than pH 7. The Richter scale measures earthquake magnitude: a magnitude 8 earthquake releases about 31,600 times more energy than a magnitude 6. In astronomy, the stellar magnitude scale uses a logarithmic relationship where each magnitude difference of 1 corresponds to a brightness ratio of 2.512. These scales all exist because human perception and natural phenomena often follow logarithmic rather than linear patterns.

Frequently Asked Questions

What is a logarithm in simple terms?

A logarithm answers the question: to what power must a base number be raised to produce a given value? The expression log_b(x) = y means that b raised to the power y equals x. For example, log_10(1000) = 3 because 10 raised to the 3rd power equals 1000. Similarly, log_2(8) = 3 because 2 raised to the 3rd power equals 8. Logarithms are the inverse of exponentiation, just as subtraction is the inverse of addition. They appear throughout science, engineering, and computing wherever quantities span multiple orders of magnitude.

What are the three most common logarithm bases and when is each used?

The three standard bases are base 10 (common logarithm, written as "log"), base e (natural logarithm, written as "ln," where e = 2.71828...), and base 2 (binary logarithm, written as "log_2"). Base 10 is used in decibel calculations, pH chemistry, the Richter earthquake scale, and engineering. Base e is used in calculus, continuous compound interest, population growth models, radioactive decay, and statistical distributions. Base 2 is used in computer science for algorithm complexity analysis, binary data storage, and information theory, where it measures the number of bits needed to represent a value.

What is the change of base formula and how do I use it?

The change of base formula is log_b(x) = ln(x) / ln(b) = log(x) / log(b). It allows you to calculate the logarithm of any base using a calculator that only has ln (natural log) and log (common log) buttons. For example, to find log_5(125): log_5(125) = log(125) / log(5) = 2.0969 / 0.6990 = 3.0000. This works because all logarithm bases are related by constant conversion factors, making it possible to convert between any two bases by dividing their logarithms.

What are the main logarithm rules and properties?

The three fundamental logarithm laws are the product rule (log_b(xy) = log_b(x) + log_b(y), which converts multiplication to addition), the quotient rule (log_b(x/y) = log_b(x) - log_b(y), which converts division to subtraction), and the power rule (log_b(x^n) = n times log_b(x), which converts exponentiation to multiplication). Additional key properties: log_b(1) = 0 for any base, log_b(b) = 1 for any base, and b raised to log_b(x) equals x. These rules are essential for simplifying logarithmic expressions in algebra and calculus.

Why can you not take the logarithm of zero or a negative number?

The logarithm log_b(x) asks what power you must raise b to in order to get x. Since any positive base raised to any real power always produces a positive result (b^y is always greater than 0 when b is greater than 0), there is no real exponent that makes b^y equal to 0 or a negative number. As x approaches 0 from the positive side, log_b(x) approaches negative infinity. This is why the natural logarithm function has a vertical asymptote at x = 0. Logarithms of negative numbers do exist in the complex number system using the formula ln(-x) = ln(x) + i times pi, but this is beyond standard real-number arithmetic.

How are logarithms used in computing and algorithm analysis?

In computer science, base-2 logarithms measure the efficiency of divide-and-conquer algorithms. Binary search on a sorted array of n elements requires at most log_2(n) comparisons — only 20 steps to search 1 million items and 30 steps for 1 billion. Balanced binary search trees have depth log_2(n), giving O(log n) time for insertions, deletions, and lookups. Sorting algorithms like merge sort and quicksort run in O(n log n) time, and log_2 also determines the number of bits needed to represent a number (a 32-bit integer can represent values up to 2 to the 32 = 4.29 billion).

Related Calculators