Sub topic 13
Solving logarithmic equations and checking for extraneous solutions
This chapter assumes you know the definition of a logarithm, how to switch between exponential and logarithmic form, and the product, quotient and power laws. You should also be able to solve linear and quadratic equations. Python examples use only the standard math module.
Why logarithmic equations need a check
A logarithmic equation has the unknown inside a logarithm, such as log_2(x) + log_2(x - 2) = 3. You can solve it with algebra you already know. One extra step is required: checking every candidate against the domain.
The argument of a logarithm must be positive. The base must be positive and not equal to 1. A value that satisfies the last line of your algebra may break one of these rules in the original equation. Such a value is an extraneous solution. It comes out of the algebra but is not a solution of the problem.
The general strategy
- Write down the domain: every argument must be greater than 0.
- Use the laws to reduce the equation to one logarithm on one side, or one logarithm on each side.
- Remove the logarithm. Use the definition for the first case, and the fact that logarithms are one-to-one for the second.
- Solve the resulting equation. It may be linear or quadratic.
- Compare each candidate with the domain from step 1. Discard any that fail.
Case 1: one logarithm equals a number
If the equation has the form log_b(expression) = c, the definition of a logarithm gives expression = b^c.
Solve log_3(2x - 1) = 2.
- Domain:
2x - 1 > 0, sox > 1/2. - Exponential form:
2x - 1 = 3^2 = 9. - Solve:
2x = 10, sox = 5. - Check:
5 > 1/2, andlog_3(9) = 2. The solution isx = 5.
Case 2: one logarithm on each side
If both sides are a single logarithm with the same base, the arguments must be equal. This works because a logarithm gives each positive input a different output.
Solve ln(x + 3) = ln(2x - 1).
- Domain:
x + 3 > 0and2x - 1 > 0. Together these givex > 1/2. - Equate arguments:
x + 3 = 2x - 1, sox = 4. - Check:
4 > 1/2. Both sides equalln 7.
The bases must match. If they differ, change the base first (see the change-of-base chapter).
Case 3: several logarithms to combine
Combine first, then follow Case 1 or Case 2. This is where extraneous solutions usually appear.
Solve log_2(x) + log_2(x - 2) = 3.
- Domain:
x > 0andx - 2 > 0. Together these givex > 2. - Product law:
log_2(x(x - 2)) = 3. - Exponential form:
x(x - 2) = 2^3 = 8. - Rearrange:
x^2 - 2x - 8 = 0, which factors as(x - 4)(x + 2) = 0. - Candidates:
x = 4andx = -2. - Check against
x > 2:x = 4passes, andx = -2fails.
Verify x = 4: log_2(4) + log_2(2) = 2 + 1 = 3. The only solution is x = 4.
A second example uses the quotient law. Solve log(x + 2) - log(x - 1) = 1, where log means base 10.
- Domain:
x > 1. - Quotient law:
log((x + 2)/(x - 1)) = 1. - Exponential form:
(x + 2)/(x - 1) = 10. - Multiply:
x + 2 = 10x - 10, so9x = 12andx = 4/3. - Check:
4/3 > 1. The quotient is(10/3)/(1/3) = 10, andlog(10) = 1.
Why extraneous solutions appear
Look again at x = -2 in the Case 3 example. The combined expression log_2(x(x - 2)) accepts it, because (-2)(-4) = 8 is positive. The original expression log_2(x) + log_2(x - 2) does not, because log_2(-2) is undefined.
The product law is only valid when both factors are positive. Applied from right to left, it replaces two conditions (x > 0 and x - 2 > 0) with one weaker condition (x(x - 2) > 0). The weaker condition lets in values the original equation never allowed. That is why you write the domain from the original equation before combining anything.
Checking candidates in code
The program below finds the roots of x^2 - 2x - 8 = 0 with the quadratic formula. It then tests each root against the domain of the original equation.
import math
# Candidates from x**2 - 2*x - 8 = 0
a, b, c = 1.0, -2.0, -8.0
disc = b * b - 4 * a * c
roots = [(-b + math.sqrt(disc)) / (2 * a), (-b - math.sqrt(disc)) / (2 * a)]
def residual(x):
# Left side minus right side of log2(x) + log2(x - 2) = 3
return math.log2(x) + math.log2(x - 2) - 3
for x in roots:
if x > 2: # domain of the ORIGINAL equation
ok = math.isclose(residual(x), 0.0, abs_tol=1e-12)
print(x, "valid:", ok)
else:
print(x, "rejected: outside the domain x > 2")It prints 4.0 valid: True and -2.0 rejected: outside the domain x > 2. Python also enforces the domain on its own, as the next block shows.
import math
try:
math.log2(-2)
except ValueError as err:
print("ValueError:", err) # ValueError: math domain errorTreat this error as a useful check. If substituting a candidate raises ValueError, that candidate is extraneous.
Unknown in the base
The unknown may also be the base. Then the base must be positive and not equal to 1, in addition to the argument being positive.
Solve log_x(9) = 2.
- Domain:
x > 0andx != 1. - Exponential form:
x^2 = 9, sox = 3orx = -3. - Check:
-3is not a valid base. Onlyx = 3remains, andlog_3(9) = 2.
Quick reference
| Form of the equation | Step that removes the log | Typical result | What to check |
|---|---|---|---|
| `log_b(f(x)) = c` | `f(x) = b^c` | Linear or quadratic equation | `f(x) > 0` |
| `log_b(f(x)) = log_b(g(x))` | `f(x) = g(x)` | Linear or quadratic equation | `f(x) > 0` and `g(x) > 0` |
| Sum or difference of logs `= c` | Combine, then use the definition | Often a quadratic | Every original argument is positive |
| `log_x(a) = c` | `x^c = a` | Power equation | `x > 0` and `x != 1` |
Common mistakes in this chapter
- Skipping the check. A quadratic gives two roots, and often one of them is invalid.
- Combining logs of different bases. The product and quotient laws need the same base.
- Writing
log(a + b)aslog(a) + log(b). Only products turn into sums. For example,log(x + 2) + log(x - 1)combines tolog((x + 2)(x - 1)), never tolog(2x + 1). - Dividing both sides by a logarithm without care. In
log(x) = 2 log(5), use the power law to getlog(x) = log(25), thenx = 25. - Checking only the combined argument. Test each original argument separately.
Exercises
Exercise
Solve log_5(x + 4) = 2 and state the domain.
Show answer
Domain: x + 4 > 0, so x > -4. Exponential form: x + 4 = 5^2 = 25, so x = 21. Since 21 > -4, the solution is x = 21. Check: log_5(25) = 2.
Exercise
Solve log(x) + log(x - 3) = 1, where log is base 10. Which candidate is extraneous?
Show answer
Domain: x > 3. Product law: log(x(x - 3)) = 1, so x^2 - 3x = 10 and x^2 - 3x - 10 = 0, which factors as (x - 5)(x + 2) = 0. The candidates are 5 and -2. Since -2 is not greater than 3, it is extraneous. The solution is x = 5. Check: log(5) + log(2) = log(10) = 1.
Exercise
Solve ln(x + 6) = ln(x) + ln(2) and check the answer.
Show answer
Domain: x > 0 (this also makes x + 6 > 0). Product law on the right: ln(x + 6) = ln(2x). Equate arguments: x + 6 = 2x, so x = 6. Since 6 > 0, it is valid. Check: ln(12) = ln(6) + ln(2).
Exercise
Write Python that tests whether x = -1 and x = 4 satisfy log2(x + 1) + log2(x - 3) = 3 by catching ValueError from math.log2.
Show answer
import math for x in (-1, 4): try: value = math.log2(x + 1) + math.log2(x - 3) print(x, math.isclose(value, 3.0)) except ValueError: print(x, "extraneous: outside the domain") x = -1 raises ValueError because log2(0) and log2(-4) are undefined, so it is extraneous. x = 4 gives log2(5) + log2(1) = log2(5), which is not 3, so the check prints False. Neither value solves the equation. The actual algebra gives (x + 1)(x - 3) = 8, so x^2 - 2x - 11 = 0 and x = 1 + sqrt(12), about 4.464.