Pre-Calculus for Programmers

Algebra foundations: the toolkit calculus never reteaches

7 / 397
Contents

Contents

Pre-Calculus for Programmers

0 of 397 complete

11 min read

Rationalising a numerator, the move calculus actually needs

Watch a perfectly sensible expression turn to rubbish as a number shrinks, then repair it with one multiplication.

Here is a quantity that turns up in the third week of every calculus course, written out in ordinary arithmetic. Take a number xx, take a small step hh beyond it, and ask how much the square root changed per unit of step:

x+h−xh\frac{\sqrt{x+h}-\sqrt{x}}{h}
The change in the square root, divided by the size of the step.

Nothing about it looks fragile. Compute it at x=4x = 4 for steps that get smaller and smaller, and watch what happens.

The same quantity, computed two waysPython

Change x = 4.0 to x = 100.0 and run it again. The collapse still happens, and the value the tidy column settles on is now different. What is it, and what is its relationship to 100?

Two things are worth staring at. For the larger steps the two columns agree to all but the last digit or two, so they are computing the same quantity. For the smallest steps the first column loses its digits, wanders, and finally sits at exactly zero, while the second column does not budge.

The first column falls apart because it subtracts two numbers that have become almost identical. 4.0000000000000001\sqrt{4.0000000000000001} and 4\sqrt{4} agree in the first sixteen digits, the machine only keeps about sixteen, so the difference it computes is made entirely of the digits it had to throw away. Dividing that by a tiny hh magnifies the damage.

The second column never subtracts anything, so there is nothing to lose. And notice where it settles: 0.250.25, which is 14\frac{1}{4}, which is 124\frac{1}{2\sqrt{4}}. That number is the answer calculus will want, and the second form is how you get to it.

Where the second form came from

It is one multiplication. In the lesson on simplest form you cleared a root off the bottom of a fraction by multiplying top and bottom by a conjugate. Here the root is on the top and it is the top you want to clear, so you do exactly the same thing for the opposite reason. This is called rationalising the numerator.

The numerator is x+h−x\sqrt{x+h}-\sqrt{x}, so its conjugate is x+h+x\sqrt{x+h}+\sqrt{x}, the same two terms with the sign flipped. Multiplying top and bottom by it is multiplying by 1.

x+h−xh⋅x+h+xx+h+x\frac{\sqrt{x+h}-\sqrt{x}}{h} \cdot \frac{\sqrt{x+h}+\sqrt{x}}{\sqrt{x+h}+\sqrt{x}}
The same value, because the second fraction is 1.
  1. The new numerator is (x+h−x)(x+h+x)(\sqrt{x+h}-\sqrt{x})(\sqrt{x+h}+\sqrt{x}), which is the pattern (a−b)(a+b)=a2−b2(a-b)(a+b) = a^{2}-b^{2} with a=x+ha = \sqrt{x+h} and b=xb = \sqrt{x}.
  2. Squaring a square root removes it: a2=x+ha^{2} = x+h and b2=xb^{2} = x.
  3. So the numerator is (x+h)−x(x+h) - x, and the xxs cancel, leaving hh on its own.
  4. The denominator is h(x+h+x)h\left(\sqrt{x+h}+\sqrt{x}\right), left as a product rather than multiplied out, which is the whole trick.
  5. The fraction is now hh(x+h+x)\dfrac{h}{h\left(\sqrt{x+h}+\sqrt{x}\right)}, and hh is a factor of both top and bottom, so it cancels.
  6. What is left is 1x+h+x\dfrac{1}{\sqrt{x+h}+\sqrt{x}}, which is the second column of the output.

Look at what the cancellation bought. In the original form, setting h=0h = 0 gives 00\frac{0}{0}, which is not a number and not a question with an answer. In the new form, setting h=0h = 0 gives 1x+x=12x\frac{1}{\sqrt{x}+\sqrt{x}} = \frac{1}{2\sqrt{x}}, an ordinary number, computed without difficulty. The two expressions are equal everywhere except at the single point where the first one refuses to speak.

The two forms, side by side
x+1−x1  =  1x+1+x\frac{\sqrt{x+1}-\sqrt{x}}{1} \;=\; \frac{1}{\sqrt{x+1}+\sqrt{x}}
00.30.60.91.20.21.653.14.556
1 over 2 root x
Direct form at x=ax = a
0.236068
Rationalised form at x=ax = a
0.236068
Where both head as hh shrinks
0.25

The first two output lines are identical for every setting, because they are the same expression. Drag h down towards 0.05 and watch the solid curve settle onto the dashed one.

A second worked example, every step

Simplify x−3x−9\dfrac{\sqrt{x}-3}{x-9}, given that xx is not 9.

  1. The root is on the top, so rationalise the numerator. The conjugate of x−3\sqrt{x}-3 is x+3\sqrt{x}+3.
  2. Multiply top and bottom by x+3\sqrt{x}+3, which is multiplying by 1.
  3. The new top is (x−3)(x+3)=(x)2−32=x−9(\sqrt{x}-3)(\sqrt{x}+3) = \left(\sqrt{x}\right)^{2} - 3^{2} = x - 9.
  4. The new bottom is (x−9)(x+3)(x-9)(\sqrt{x}+3), deliberately left unmultiplied.
  5. Now x−9x-9 is a factor of both, so it cancels, leaving 1x+3\dfrac{1}{\sqrt{x}+3}.
  6. Check with a number. At x=16x = 16 the original is 4−316−9=17\frac{4-3}{16-9} = \frac{1}{7}, and the new form is 14+3=17\frac{1}{4+3} = \frac{1}{7}.
  7. At x=9x = 9 the original is 00\frac{0}{0} and the new form is 16\frac{1}{6}. That number, which the original could not produce, is the point of the exercise.
Checking the second example at several valuesPython

Add 9.0 to the list and run it again: one column fails and the other does not. Then change both 3s to 2s and both 9s to 4s, which checks the same manoeuvre for x−2x−4\dfrac{\sqrt{x}-2}{x-4}.

Check yourself

To simplify x+5−5x\dfrac{\sqrt{x+5}-\sqrt{5}}{x}, what should the top and bottom both be multiplied by?

Why does the rationalised form of x+h−xh\dfrac{\sqrt{x+h}-\sqrt{x}}{h} keep its accuracy in a computer when the original does not?

Because it never subtracts two nearly equal numbers. In the original, x+h\sqrt{x+h} and x\sqrt{x} agree in almost all their digits when hh is tiny, so their difference is built from whatever digits the machine happened to keep, and dividing by a tiny hh then blows that error up. In 1x+h+x\frac{1}{\sqrt{x+h}+\sqrt{x}} the two roots are added, which loses nothing, and no small number is divided by. The algebra and the numerical stability improved for the same reason: the cancellation was done exactly, on paper, instead of approximately, in the machine.

All lessons in Pre-Calculus for Programmers