TExcelTAD
Home › Algebra › Exponential Equations

Exponential Equations

An exponential equation has the unknown in the exponent, like 2x=322^x = 32 or 1.05t=21.05^t = 2. You solve it either by writing both sides as powers of the same base, or by taking a logarithm of both sides. Programmers meet these equations whenever they ask "how many steps until…": doubling times, retry backoff, bits needed to count something.

Method 1: same base

If both sides can be written as powers of one base bb (b>0b > 0, b≠1b \ne 1), the exponents must be equal, because bxb^x is one-to-one:

bu=bv⇒u=vb^u = b^v \quad\Rightarrow\quad u = v
2x+1=322x+1=25x+1=5x=4\begin{aligned} 2^{x+1} &= 32 \\ 2^{x+1} &= 2^5 \\ x + 1 &= 5 \\ x &= 4 \end{aligned}
9x=27x−1(32)x=(33)x−132x=33x−32x=3x−3⇒x=3\begin{aligned} 9^x &= 27^{x-1} \\ (3^2)^x &= (3^3)^{x-1} \\ 3^{2x} &= 3^{3x-3} \\ 2x &= 3x - 3 \quad\Rightarrow\quad x = 3 \end{aligned}

This works when the numbers are "nice" powers (2, 4, 8, 16, 32…, or 3, 9, 27, 81…). Fractions and roots fit in too: 18=2−3\frac{1}{8} = 2^{-3} and 2=21/2\sqrt{2} = 2^{1/2} (see rational exponents).

Method 2: take logarithms

When no common base exists, apply a logarithm to both sides and use log⁡(ax)=x⋅log⁡(a)\log(a^x) = x \cdot \log(a) to bring the unknown down (log laws):

5x=40x⋅ln⁡5=ln⁡40x=ln⁡40ln⁡5≈2.2920\begin{aligned} 5^x &= 40 \\ x \cdot \ln 5 &= \ln 40 \\ x &= \frac{\ln 40}{\ln 5} \approx 2.2920 \end{aligned}

Any base of logarithm works, as long as you use the same one on both sides. With the unknown on both sides, collect the xx terms:

2x=3x−1x⋅ln⁡2=(x−1)⋅ln⁡3x⋅ln⁡2−x⋅ln⁡3=−ln⁡3x⋅(ln⁡3−ln⁡2)=ln⁡3x=ln⁡3ln⁡(3/2)≈2.7095\begin{aligned} 2^x &= 3^{x-1} \\ x \cdot \ln 2 &= (x - 1) \cdot \ln 3 \\ x \cdot \ln 2 - x \cdot \ln 3 &= -\ln 3 \\ x \cdot (\ln 3 - \ln 2) &= \ln 3 \\ x &= \frac{\ln 3}{\ln(3/2)} \approx 2.7095 \end{aligned}

Tip: Isolate the power first. In 4⋅3x+1=1094 \cdot 3^x + 1 = 109, subtract 1 and divide by 4 to get 3x=273^x = 27, so x=3x = 3. Taking logs too early leaves you with log⁡(4⋅3x+1)\log(4 \cdot 3^x + 1), which no law simplifies.

Method 3: a quadratic in disguise

When the same exponential appears with exponents xx and 2x2x, substitute u=bxu = b^x:

4x−6⋅2x+8=04x=(2x)2=u2u2−6u+8=0(u−2)(u−4)=0u=2 or u=42x=2⇒x=12x=4⇒x=2\begin{aligned} 4^x - 6 \cdot 2^x + 8 &= 0 && 4^x = (2^x)^2 = u^2 \\ u^2 - 6u + 8 &= 0 \\ (u - 2)(u - 4) &= 0 && u = 2 \text{ or } u = 4 \\ 2^x = 2 \Rightarrow x = 1 &\qquad 2^x = 4 \Rightarrow x = 2 \end{aligned}

Because bxb^x is always positive, any negative uu is rejected: it gives no real xx.

Checking with Python

python · try it yourself
import math
import sympy as sp

print("5^x = 40     :", math.log(40) / math.log(5))
print("check        :", 5 ** (math.log(40) / math.log(5)))
x2 = math.log(3) / math.log(1.5)
print("2^x = 3^(x-1):", x2, 2 ** x2, 3 ** (x2 - 1))

x = sp.symbols("x", real=True)
print(sp.solve(sp.Eq(9**x, 27**(x - 1)), x))
print(sp.solve(4**x - 6 * 2**x + 8, x))
sol = sp.solve(sp.Eq(2**x, 3**(x - 1)), x)
print(sol, [float(s) for s in sol])
5^x = 40     : 2.292029674220179
check        : 40.0
2^x = 3^(x-1): 2.709511291351455 6.5410003487433785 6.541000348743379
[3]
[1, 2]
[-log(3)/(-log(3) + log(2))] [2.709511291351455]

SymPy writes exact answers with log, its name for ln. The two sides of 2x=3x−12^x = 3^{x-1} agree to about 15 digits but differ in the last one: floating-point rounding, not a wrong answer. Compare floats with a tolerance (math.isclose), never with ==.

In software

Exponential equations answer "how many repetitions?" questions. The answer is usually not a whole number, so you round up to the next integer step with math.ceil.

Question Equation Solution
Years for money to double at 5% 1.05t=21.05^t = 2 t=ln⁡2/ln⁡1.05t = \ln 2 / \ln 1.05
Bits to store NN different values 2b≥N2^b \ge N b=⌈log⁡2N⌉b = \lceil \log_2 N \rceil
Retries until backoff passes 60 s (0.1 s, doubling) 0.1⋅2k≥600.1 \cdot 2^k \ge 60 k=⌈log⁡2600⌉k = \lceil \log_2 600 \rceil
Half-lives until 1% of a cache weight remains 0.5n=0.010.5^n = 0.01 n=ln⁡0.01/ln⁡0.5n = \ln 0.01 / \ln 0.5
python · try it yourself
import math

t = math.log(2) / math.log(1.05)
print(f"doubling at 5%: {t:.4f} years -> {math.ceil(t)} whole years")

for n in [10, 256, 1000, 1_000_000]:
    print(f"{n:>9} values need {math.ceil(math.log2(n))} bits")

k = math.ceil(math.log2(60 / 0.1))
print("retry delays:", [round(0.1 * 2**i, 1) for i in range(k + 1)])
print("first delay over 60 s is retry", k)
doubling at 5%: 14.2067 years -> 15 whole years
       10 values need 4 bits
      256 values need 8 bits
     1000 values need 10 bits
  1000000 values need 20 bits
retry delays: [0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 51.2, 102.4]
first delay over 60 s is retry 10

Note: For exact powers of two, math.log2 is exact (log⁡2256=8.0\log_2 256 = 8.0), but in general a float log can land a hair above or below a whole number. For integers, (n - 1).bit_length() gives ⌈log⁡2n⌉\lceil \log_2 n \rceil with no rounding risk.

Growth and decay models of this shape are the exponential functions of pre-calculus, and their rates of change are in derivatives of exponentials.

Exercises

Exercise 1: Same base

Solve 8x−2=4x+18^{x-2} = 4^{x+1}.

Answer

x=8x = 8

Solution
(23)x−2=(22)x+123x−6=22x+23x−6=2x+2x=8\begin{aligned} (2^3)^{x-2} &= (2^2)^{x+1} \\ 2^{3x-6} &= 2^{2x+2} \\ 3x - 6 &= 2x + 2 \\ x &= 8 \end{aligned}

Check: 86=2188^6 = 2^{18} and 49=2184^9 = 2^{18}.

Exercise 2: Isolate, then log

Solve 3⋅2x−5=403 \cdot 2^x - 5 = 40 exactly and to 4 decimal places.

Answer

x=log⁡215=ln⁡15/ln⁡2≈3.9069x = \log_2 15 = \ln 15 / \ln 2 \approx 3.9069

Solution
3⋅2x=452x=15x=log⁡215=ln⁡15ln⁡2\begin{aligned} 3 \cdot 2^x &= 45 \\ 2^x &= 15 \\ x &= \log_2 15 = \frac{\ln 15}{\ln 2} \end{aligned}
python · try it yourself
import math
x = math.log(15) / math.log(2)
print(round(x, 4), 3 * 2**x - 5)
3.9069 40.00000000000001

Exercise 3: Disguised quadratic

Solve 9x−4⋅3x+3=09^x - 4 \cdot 3^x + 3 = 0.

Answer

x=0x = 0 or x=1x = 1

Solution

Let u=3xu = 3^x, so 9x=u29^x = u^2:

u2−4u+3=0(u−1)(u−3)=0u=1⇒3x=1⇒x=0u=3⇒3x=3⇒x=1\begin{aligned} u^2 - 4u + 3 &= 0 \\ (u - 1)(u - 3) &= 0 \\ u = 1 &\Rightarrow 3^x = 1 \Rightarrow x = 0 \\ u = 3 &\Rightarrow 3^x = 3 \Rightarrow x = 1 \end{aligned}

Exercise 4: Loot drop streak (code)

An item drops with probability 3% per kill, independently. The chance of no drop in nn kills is 0.97n0.97^n. Find the smallest whole nn for which the chance of at least one drop is at least 90%, and confirm with a loop.

Answer

n=76n = 76 kills (0.9776≈0.09890.97^{76} \approx 0.0989).

Solution

We need 1−0.97n≥0.91 - 0.97^n \ge 0.9, so 0.97n≤0.10.97^n \le 0.1. Taking ln flips the inequality, because ln⁡0.97\ln 0.97 is negative:

n⋅ln⁡0.97≤ln⁡0.1n≥ln⁡0.1ln⁡0.97≈75.6⇒n=76\begin{aligned} n \cdot \ln 0.97 &\le \ln 0.1 \\ n &\ge \frac{\ln 0.1}{\ln 0.97} \approx 75.6 \quad\Rightarrow\quad n = 76 \end{aligned}
python · try it yourself
import math
print(math.log(0.1) / math.log(0.97))
n = 0
while 1 - 0.97**n < 0.9:
    n += 1
print(n, round(0.97**n, 4))
75.59569940058392
76 0.0988

Test yourself

Solve 32x=813^{2x} = 81.

  1. x=4x = 4
  2. x=2x = 2
  3. x=27x = 27
  4. x=12x = \frac{1}{2}

Which expression solves 7x=207^x = 20?

  1. 207\frac{20}{7}
  2. ln⁡7ln⁡20\frac{\ln 7}{\ln 20}
  3. ln⁡20ln⁡7\frac{\ln 20}{\ln 7}
  4. ln⁡(20/7)\ln(20 / 7)

In 4x−3⋅2x−4=04^x - 3 \cdot 2^x - 4 = 0, the substitution u=2xu = 2^x gives u=4u = 4 or u=−1u = -1. What are the solutions?

  1. x=2x = 2 only
  2. x=2x = 2 and x=−1x = -1
  3. x=2x = 2 and x=0x = 0
  4. No solution