Sub topic 2
Isolating a variable that appears once
This chapter assumes you can solve one-variable linear equations, work with fractions and negative numbers, and apply the order of operations.
To isolate a variable means rewriting a formula so the target variable stands alone on one side. Whatever you do to one side, do to the other so the equation stays balanced.
Undoing operations in reverse order
Undo operations in the reverse of the order you would evaluate them. Undo addition and subtraction before multiplication and division.
Solve y = 3x - 7 for x:
- Add 7 to both sides: y + 7 = 3x.
- Divide both sides by 3: x = (y + 7) / 3.
For a formula with a multiplier and an offset, such as F = (9/5)C + 32, solve for C the same way:
def f_to_c(f):
# From F = 9/5 * C + 32: subtract 32, then multiply by 5/9
return 5 * (f - 32) / 9
print(f_to_c(212)) # 100.0
print(f_to_c(32)) # 0.0When the variable appears in several terms
If the target variable appears more than once, collect those terms on one side, then factor the variable out.
For ax + b = cx + d, move the x terms to the left and the constants to the right: (a - c)x = d - b. Then divide:
x = (d - b) / (a - c)
This works only when a - c is not zero. If a equals c, you cannot divide by the coefficient.
Clearing fractions and solving for a variable in a denominator
When the target variable sits in a denominator, multiply through by the denominators first, or take reciprocals. For 1/R = 1/R1 + 1/R2, solving for R2 gives R2 = R * R1 / (R1 - R).
def second_resistor(r_total, r1):
# From 1/R = 1/R1 + 1/R2: R2 = R * R1 / (R1 - R)
if r1 == r_total:
raise ValueError("R1 must differ from R; otherwise R2 is undefined")
return r_total * r1 / (r1 - r_total)
print(second_resistor(2, 6)) # 3.0> Note: Every rearranged formula has restrictions. In the resistor formula, R1 cannot equal R, and no denominator can be zero.
Exercise
Solve 3x + 4 = 7x - 8 for x.
Show answer
Collect the x terms: 12 = 4x, so x = 3. Check: 3(3) + 4 = 13 and 7(3) - 8 = 13.