TExcelTAD
Home › Algebra › Logarithmic Equations

Logarithmic Equations

A logarithmic equation has the unknown inside a logarithm, like log⁡2(x+3)=5\log_2(x + 3) = 5. The plan is always the same: combine the logs into one, rewrite the equation in exponential form, solve, and then check every answer, because logarithms only accept positive inputs and the algebra can produce answers that don't fit.

The key move: exponential form

By definition (see what a logarithm is):

log⁡b(y)=k  ⟺  y=bk(b>0, b≠1, y>0)\log_b(y) = k \quad\iff\quad y = b^k \qquad (b > 0,\ b \ne 1,\ y > 0)

So a single log equal to a number turns into an ordinary equation:

log⁡2(x+3)=5x+3=25=32x=29\begin{aligned} \log_2(x + 3) &= 5 \\ x + 3 &= 2^5 = 32 \\ x &= 29 \end{aligned}
ln⁡(2x−1)=32x−1=e3x=e3+12≈10.5428\begin{aligned} \ln(2x - 1) &= 3 \\ 2x - 1 &= e^3 \\ x &= \frac{e^3 + 1}{2} \approx 10.5428 \end{aligned}

The unknown can also be the base: log⁡x(81)=4\log_x(81) = 4 means x4=81x^4 = 81, so x=3x = 3 (the base must be positive, so −3-3 is rejected).

Combining logs first

When there are several logs, use the log laws to merge them into one:

Law Use
log⁡a+log⁡b=log⁡(ab)\log a + \log b = \log(ab) two logs added
log⁡a−log⁡b=log⁡(a/b)\log a - \log b = \log(a/b) two logs subtracted
k⋅log⁡a=log⁡(ak)k \cdot \log a = \log(a^k) a number in front

Example with base-10 logs:

log⁡(x)+log⁡(x−3)=1log⁡(x(x−3))=1x(x−3)=101x2−3x−10=0(x−5)(x+2)=0x=5 or x=−2\begin{aligned} \log(x) + \log(x - 3) &= 1 \\ \log(x(x - 3)) &= 1 \\ x(x - 3) &= 10^1 \\ x^2 - 3x - 10 &= 0 \\ (x - 5)(x + 2) &= 0 && x = 5 \text{ or } x = -2 \end{aligned}

Now check the domain: log⁡(−2)\log(-2) is undefined, so x=−2x = -2 is an extraneous solution. The only answer is x=5x = 5 (check: log⁡5+log⁡2=log⁡10=1\log 5 + \log 2 = \log 10 = 1).

Note: Merging logs widens the domain. log⁡(x(x−3))\log(x(x - 3)) is defined for x=−2x = -2, because (−2)(−5)=10>0(-2)(-5) = 10 > 0, but the original log⁡(x)\log(x) is not. That is how the fake solution sneaks in.

Log equals log

If both sides are single logs of the same base, drop the logs (log is one-to-one), then check:

ln⁡(2x+1)=ln⁡(x+4)2x+1=x+4x=3(both sides ln⁡7 ✓)\begin{aligned} \ln(2x + 1) &= \ln(x + 4) \\ 2x + 1 &= x + 4 \\ x &= 3 && \text{(both sides } \ln 7\ \checkmark\text{)} \end{aligned}
log⁡3(x2−4)=log⁡3(3x)x2−4=3xx2−3x−4=0⇒x=4 or x=−1= x=−1 makes 3x negative⇒only x=4\begin{aligned} \log_3(x^2 - 4) &= \log_3(3x) \\ x^2 - 4 &= 3x \\ x^2 - 3x - 4 &= 0 \quad\Rightarrow\quad x = 4 \text{ or } x = -1 \\ &\phantom{=}\ x = -1 \text{ makes } 3x \text{ negative} \Rightarrow \text{only } x = 4 \end{aligned}

Solving and checking in code

Let SymPy solve, then filter candidates by plugging them into the original equation. Below, ok tests the domain of every log; that check is what removes extraneous roots.

python · try it yourself
import math
import sympy as sp

x = sp.symbols("x")
merged = sp.Eq(x * (x - 3), 10)            # from log(x) + log(x-3) = 1
candidates = sp.solve(merged, x)
print("candidates:", candidates)

def ok(v):
    return v > 0 and v - 3 > 0

for v in candidates:
    if ok(v):
        print(v, "->", math.log10(v) + math.log10(v - 3))
    else:
        print(v, "-> rejected (log of a non-positive number)")

print(sp.solve(sp.Eq(sp.log(2*x - 1), 3), x))
print(float((sp.exp(3) + 1) / 2))
candidates: [-2, 5]
-2 -> rejected (log of a non-positive number)
5 -> 1.0
[1/2 + exp(3)/2]
10.542768461593834

In software

Logs turn "how many times did we multiply?" into "how far did we add?". Common equations a programmer solves:

  • Digits of a number: nn has ⌊log⁡10n⌋+1\lfloor \log_{10} n \rfloor + 1 decimal digits. Solving ⌊log⁡10n⌋+1=7\lfloor \log_{10} n \rfloor + 1 = 7 gives the range 106≤n<10710^6 \le n < 10^7.
  • Decibels: a gain of GG dB means a power ratio P/P0P/P_0 with G=10⋅log⁡10(P/P0)G = 10 \cdot \log_{10}(P/P_0). Solving for the ratio gives P/P0=10G/10P/P_0 = 10^{G/10}. Audio volume sliders and Wi-Fi signal levels (dBm) use this.
  • Balanced trees and binary search: a search over nn sorted items takes about log⁡2n\log_2 n steps. "How many items can 20 steps cover?" means log⁡2n=20\log_2 n = 20, so n=220=1 048 576n = 2^{20} = 1\,048\,576 (binary search).
  • Information: an event with probability pp carries −log⁡2p-\log_2 p bits; "which pp carries 5 bits?" gives p=2−5=132p = 2^{-5} = \frac{1}{32}.
python · try it yourself
import math

for n in [7, 999, 1000, 4_096_000]:
    print(f"{n:>9} has {math.floor(math.log10(n)) + 1} digits, len(str) = {len(str(n))}")

for gain_db in [3, 10, -6, 20]:
    print(f"{gain_db:+} dB -> power x{10 ** (gain_db / 10):.3f}")

print("items covered by 20 halvings:", 2 ** 20)
        7 has 1 digits, len(str) = 1
      999 has 3 digits, len(str) = 3
     1000 has 4 digits, len(str) = 4
  4096000 has 7 digits, len(str) = 7
+3 dB -> power x1.995
+10 dB -> power x10.000
-6 dB -> power x0.251
+20 dB -> power x100.000
items covered by 20 halvings: 1048576

Tip: For very large integers, prefer len(str(n)) or n.bit_length() over float logs. A float log of 1015−110^{15} - 1 can round to exactly 15.0 and give one digit too many.

The functions behind these equations, their graphs and inverses are covered in exponential and logarithmic functions.

Exercises

Exercise 1: Rewrite and solve

Solve log⁡5(3x−1)=2\log_5(3x - 1) = 2.

Answer

x=263≈8.667x = \frac{26}{3} \approx 8.667

Solution
3x−1=52=253x=26x=263\begin{aligned} 3x - 1 &= 5^2 = 25 \\ 3x &= 26 \\ x &= \frac{26}{3} \end{aligned}

Check: 3⋅263−1=25>03 \cdot \frac{26}{3} - 1 = 25 > 0, and log⁡525=2\log_5 25 = 2. ✓

Exercise 2: Spot the extraneous root

Solve log⁡2(x)+log⁡2(x+6)=4\log_2(x) + \log_2(x + 6) = 4.

Answer

x=2x = 2 (x=−8x = -8 is extraneous)

Solution
log⁡2(x(x+6))=4x2+6x=16x2+6x−16=0(x+8)(x−2)=0x=−8 or x=2\begin{aligned} \log_2(x(x + 6)) &= 4 \\ x^2 + 6x &= 16 \\ x^2 + 6x - 16 &= 0 \\ (x + 8)(x - 2) &= 0 && x = -8 \text{ or } x = 2 \end{aligned}

log⁡2(−8)\log_2(-8) is undefined, so only x=2x = 2 survives. Check: log⁡22+log⁡28=1+3=4\log_2 2 + \log_2 8 = 1 + 3 = 4. ✓

Exercise 3: Difference of logs

Solve ln⁡(x+5)−ln⁡(x−1)=ln⁡3\ln(x + 5) - \ln(x - 1) = \ln 3.

Answer

x=4x = 4

Solution
ln⁡(x+5x−1)=ln⁡3x+5x−1=3x+5=3x−3x=4\begin{aligned} \ln\left(\frac{x + 5}{x - 1}\right) &= \ln 3 \\ \frac{x + 5}{x - 1} &= 3 \\ x + 5 &= 3x - 3 \\ x &= 4 \end{aligned}

Check: both x+5=9x + 5 = 9 and x−1=3x - 1 = 3 are positive, and ln⁡9−ln⁡3=ln⁡3\ln 9 - \ln 3 = \ln 3. ✓

Exercise 4: Volume slider (code)

A volume slider maps a position ss from 0 to 100 to a gain of G=40⋅log⁡10(s/100)G = 40 \cdot \log_{10}(s/100) dB (so s=100s = 100 is 0 dB). Solve for ss when G=−12G = -12 dB, by hand and with code.

Answer

s=100⋅10−0.3≈50.12s = 100 \cdot 10^{-0.3} \approx 50.12

Solution
−12=40⋅log⁡10(s/100)log⁡10(s/100)=−0.3s/100=10−0.3s=100⋅10−0.3≈50.12\begin{aligned} -12 &= 40 \cdot \log_{10}(s/100) \\ \log_{10}(s/100) &= -0.3 \\ s/100 &= 10^{-0.3} \\ s &= 100 \cdot 10^{-0.3} \approx 50.12 \end{aligned}
python · try it yourself
import math
s = 100 * 10 ** (-12 / 40)
print(round(s, 2), round(40 * math.log10(s / 100), 6))
50.12 -12.0

Test yourself

Solve log⁡3(x)=4\log_3(x) = 4.

  1. x=12x = 12
  2. x=64x = 64
  3. x=43x = \frac{4}{3}
  4. x=81x = 81

Why must you check solutions of log equations?

  1. Because logs are slow to compute
  2. Because merging logs can create solutions that make an original log's input zero or negative
  3. Because SymPy is unreliable
  4. Because every log equation has two solutions

log⁡(x)+log⁡(4)=2\log(x) + \log(4) = 2 (base 10). What is xx?

  1. 25
  2. 96
  3. 12\frac{1}{2}
  4. 8