Pre-Calculus for Programmers

Algebra foundations: the toolkit calculus never reteaches

12 / 397
Contents

Contents

Pre-Calculus for Programmers

0 of 397 complete

11 min read

Fractions with letters in them

Cancelling is legal for factors and never for terms, and everything else follows from ordinary fraction arithmetic.

A rational expression is one polynomial divided by another, such as x2−9x−3\dfrac{x^{2}-9}{x-3}. Somebody claims that this one is the same as x+3x+3. Test the claim before believing it.

Is the fraction really x + 3?Python

Add 3.0 to the list and run it again. Every other row agrees and that one fails. Then try 2.999999 and 3.000001 and watch the fraction come very close to a particular number.

The claim is right everywhere except at x=3x = 3, where the fraction is 00\frac{0}{0} and x+3x+3 is a perfectly ordinary 6. The algebra shows why: x2−9x−3=(x−3)(x+3)x−3\frac{x^{2}-9}{x-3} = \frac{(x-3)(x+3)}{x-3}, and the matching factor cancels, leaving x+3x+3 with the note that xx cannot be 3.

The value that has to be excluded is not a technicality. Producing a fraction that says 00\frac{0}{0}, cancelling, and reading off the value the tidy version gives is the whole mechanism of a derivative.

Cancelling: factors yes, terms no

A factor is something being multiplied. A term is something being added. Cancelling means dividing top and bottom by the same quantity, and that only works on factors, because only a factor divides the whole numerator.

The cancellation that is not allowedPython

Only one value of x makes the two columns agree. Find it by editing the list. Then change both 3s to 5s and find the value that works for those.

Multiplying and dividing

Multiplying rational expressions is the same as multiplying numeric fractions: tops times tops, bottoms times bottoms. The work is all in factoring first so that the cancelling can happen before anything is multiplied out.

x2−4x2+5x+6⋅x+3x−2=(x−2)(x+2)(x+2)(x+3)⋅x+3x−2=1\frac{x^{2}-4}{x^{2}+5x+6} \cdot \frac{x+3}{x-2} = \frac{(x-2)(x+2)}{(x+2)(x+3)} \cdot \frac{x+3}{x-2} = 1
Every factor found a partner. Multiplying out first would have produced two cubics and hidden this entirely.

That example collapsed to 1 because every factor found a partner, which is tidier than the usual case. Here is one where something survives, every step.

Simplify x2−1x2+4x+3⋅x+3x\dfrac{x^{2}-1}{x^{2}+4x+3}\cdot\dfrac{x+3}{x}.

  1. Factor every top and every bottom before touching anything else. x2−1x^{2}-1 is a difference of squares, so it is (x−1)(x+1)(x-1)(x+1).
  2. x2+4x+3x^{2}+4x+3 needs two numbers multiplying to 3 and adding to 4, which are 1 and 3, so it is (x+1)(x+3)(x+1)(x+3).
  3. The other two pieces, x+3x+3 and xx, are already as factored as they get.
  4. Write the whole thing as one fraction, tops multiplied and bottoms multiplied: (x−1)(x+1)(x+3)(x+1)(x+3) x\dfrac{(x-1)(x+1)(x+3)}{(x+1)(x+3)\,x}.
  5. Cancel the factors that appear top and bottom. (x+1)(x+1) appears in both, so it goes. (x+3)(x+3) appears in both, so it goes too.
  6. What is left is x−1x\dfrac{x-1}{x}.
  7. Check at x=2x = 2: the original is 4−14+8+3⋅52=315⋅52=12\frac{4-1}{4+8+3}\cdot\frac{5}{2} = \frac{3}{15}\cdot\frac{5}{2} = \frac{1}{2}, and the answer is 2−12=12\frac{2-1}{2} = \frac{1}{2}.
  8. Note what is excluded. The cancelled factors were zero at x=−1x = -1 and x=−3x = -3, and the xx on the bottom rules out x=0x = 0, so the answer holds for every xx except those three.

Dividing is multiplying by the reciprocal, that is, by the fraction turned upside down. ab÷cd=ab⋅dc\dfrac{a}{b} \div \dfrac{c}{d} = \dfrac{a}{b}\cdot\dfrac{d}{c}. Flip the second one only, never the first.

Simplify x2−4x2+6x+9÷x−2x+3\dfrac{x^{2}-4}{x^{2}+6x+9} \div \dfrac{x-2}{x+3}.

  1. Turn the division into a multiplication by flipping the second fraction: x2−4x2+6x+9⋅x+3x−2\dfrac{x^{2}-4}{x^{2}+6x+9}\cdot\dfrac{x+3}{x-2}.
  2. Factor what is left. x2−4=(x−2)(x+2)x^{2}-4 = (x-2)(x+2), a difference of squares.
  3. x2+6x+9x^{2}+6x+9 needs two numbers multiplying to 9 and adding to 6, which are 3 and 3, so it is (x+3)(x+3)(x+3)(x+3).
  4. As one fraction: (x−2)(x+2)(x+3)(x+3)(x+3)(x−2)\dfrac{(x-2)(x+2)(x+3)}{(x+3)(x+3)(x-2)}.
  5. Cancel (x−2)(x-2) from top and bottom, and cancel one (x+3)(x+3) against one of the two on the bottom. One (x+3)(x+3) stays behind on the bottom, because there were two down there and only one up top.
  6. The answer is x+2x+3\dfrac{x+2}{x+3}.
  7. Check at x=1x = 1: the original is 1−41+6+9÷1−21+3=−316÷−14=−316⋅4−1=34\frac{1-4}{1+6+9} \div \frac{1-2}{1+3} = \frac{-3}{16} \div \frac{-1}{4} = \frac{-3}{16}\cdot\frac{4}{-1} = \frac{3}{4}, and the answer is 1+21+3=34\frac{1+2}{1+3} = \frac{3}{4}.
Checking a multiplication that does not collapsePython

Change (x - 1) / x to (x + 1) / x and run it again. Every row now disagrees, which is what cancelling the wrong bracket looks like. Put it back, then change 2.0 to -0.999 and run it again: the two columns still agree, even a thousandth of a step away from the value x=−1x = -1 that the original cannot handle at all.

Adding and subtracting: the common denominator

Fractions can only be added when their denominators match, because ad+bd=a+bd\frac{a}{d}+\frac{b}{d} = \frac{a+b}{d} needs the same dd in both. When they do not match, each fraction is multiplied by a disguised 1 until they do.

The lowest common denominator, or LCD, is built from the factorisations: take every distinct factor that appears anywhere, each raised to the highest power it reaches in any one denominator.

Work 1x2−1+2x+1\dfrac{1}{x^{2}-1} + \dfrac{2}{x+1} all the way through.

  1. Factor every denominator. x2−1x^{2}-1 is a difference of squares, so it is (x−1)(x+1)(x-1)(x+1). The second denominator is already factored: (x+1)(x+1).
  2. Collect the distinct factors: (x−1)(x-1) and (x+1)(x+1). Each appears to the first power at most, so the LCD is (x−1)(x+1)(x-1)(x+1).
  3. The first fraction already has that denominator, so it is left alone: 1(x−1)(x+1)\dfrac{1}{(x-1)(x+1)}.
  4. The second is missing the factor (x−1)(x-1), so multiply it by x−1x−1\dfrac{x-1}{x-1}, which is 1: it becomes 2(x−1)(x−1)(x+1)\dfrac{2(x-1)}{(x-1)(x+1)}.
  5. Now the denominators match, so add the numerators: 1+2(x−1)=1+2x−2=2x−11 + 2(x-1) = 1 + 2x - 2 = 2x - 1.
  6. The sum is 2x−1(x−1)(x+1)\dfrac{2x-1}{(x-1)(x+1)}, which can also be written 2x−1x2−1\dfrac{2x-1}{x^{2}-1}.
  7. Can it simplify further? The top would have to share a factor with the bottom, and 2x−12x-1 is zero at x=12x = \frac{1}{2} while the bottom is zero at x=1x = 1 and at x=−1x = -1, so no.
  8. Check at x=3x = 3: the original is 18+24=0.625\frac{1}{8}+\frac{2}{4} = 0.625, and the answer is 58=0.625\frac{5}{8} = 0.625.
Checking the additionPython

Change the 2 / to 5 / and run it again. The columns disagree. Redo step 5 with a 5 in it, then edit combined until they match.

Simplify x2−x−6x2−9\dfrac{x^{2}-x-6}{x^{2}-9} and state the value of xx that must be excluded.

Factor both. The top is x2−x−6=(x−3)(x+2)x^{2}-x-6 = (x-3)(x+2), since −3-3 and 2 multiply to −6-6 and add to −1-1. The bottom is a difference of squares, (x−3)(x+3)(x-3)(x+3). The factor (x−3)(x-3) cancels, leaving x+2x+3\frac{x+2}{x+3}, valid for x≠3x \ne 3. The value x=−3x = -3 was never allowed in the first place and is still not allowed, since the simplified form is also undefined there.

Check yourself

Which of these is 3x+4y\dfrac{3}{x} + \dfrac{4}{y} written as a single fraction?

All lessons in Pre-Calculus for Programmers