The difference quotient, computed
Two points on a curve, rise over run between them, and a number worth chasing.
A straight road has one steepness. If it climbs 30 metres over 300 metres of ground, it leans at 30 divided by 300, one in ten, and it leans at one in ten everywhere along it. Measure between any two points you like and the answer is the same. That single number is what rise over run measures.
A curve has no single steepness. A ball rolling down a ramp starts slowly and finishes quickly, so any one number would be wrong nearly everywhere on the way down. But rise over run still works perfectly well between any two points you choose to pick. Pick two, measure the rise, measure the run, divide. Nothing about that requires the thing between them to be straight.
Here is the ball. Start the clock when it is released, and after t seconds it has travelled t * t metres down the ramp. A real ramp has a constant in front of that, decided by the angle and by gravity; this one is chosen so the arithmetic stays visible.
Change the list to [3.0, 3.5, 4.0] and run it again. Does the ball cover more ground in the first half of that second or in the second half?
Between 3 seconds and 4 seconds the ball goes from 9 metres to 16 metres. That is 7 metres in 1 second, so its average speed over that second was 7 metres per second. Nothing in that sentence is new to you. It is rise over run, with time playing the part of the run.
Shrinking the interval
Now the question this course is about. Not how fast the ball went on average over that second, but how fast it was going at the instant the clock read 3. The trouble is that an instant has no width. Between 3 and 3 the rise is 0 and the run is 0, and 0 divided by 0 is not a number; it is a request the arithmetic has to refuse.
So do the only thing available. Keep the interval, but make it short. Measure the average speed between 3 and 3.1 seconds, then between 3 and 3.01. The interval never becomes an instant, but it gets small enough that the difference stops mattering, and you can watch what the answers do on the way.
Give the length of the interval a name. Call it h, so the two times are a and a + h, where a is the moment you care about. The rise is travelled(a + h) - travelled(a) and the run is h.
Change a to 5 and run it again. The four answers crowd around a different number. Read it off, then try a = 10.
The four answers are 7, 6.5, 6.1 and 6.01. They are crowding around 6, and they are doing it in an orderly way: every time h is divided by ten, the gap between the answer and 6 is divided by ten as well. Nothing so far has proved that 6 is the answer. But 6 is plainly what the numbers are up to.
The thing you just computed has a name
For a function f, a fixed point a and a step h, the quantity you evaluated is called the difference quotient of f at a. Difference, because the top is the difference between two values of the function. Quotient, because you divide by the step.
Two things about it deserve to be said precisely. First, it is exact. It is not an estimate of anything and it has no error in it; it is the true average rate at which f changed over the interval from a to a + h. Second, it is a function of h. Feed it a different step and you get a different number, which is exactly what the loop showed.
It also has a picture. Mark the two points and on the graph and draw the straight line through them. A line that cuts a curve at two places is called a secant line, from the Latin for cutting. The difference quotient is the slope of that line, no more and no less.
- Rise,
- 7
- Run,
- 1
- Difference quotient
- 7
Drag h down towards zero and watch the dashed line settle onto one particular lean. Then drag a and watch that lean change.
Before running anything: what is the difference quotient of at with ?
, which is the second number the loop printed. The arithmetic is worth doing by hand once, because the exam will not have the loop in it.
Doing it with algebra instead
The loop prints numbers. Algebra says why the numbers look like that. Take the difference quotient of at a general point and expand the top.
So for this function the difference quotient is exactly , with no approximation anywhere in the derivation. At that is , which is why gave 7, gave 6.1 and gave 6.01. The digits trailing after the 6 in every printed line are simply the digits of h.
By hand, simplify the difference quotient of at a general point , until no is left in the denominator.
The top is , which expands to . Every term has an , so dividing gives . Compare that with the plain answer of : adding to the function has added 5 to the quotient, and nothing else.
None of this is special to . Any function you can evaluate at two points has a difference quotient, and the same three lines of code compute it. Change the function and see.
Change f to return x * x * x, then to return 5 * x + 2. One of those three gives the same answer for every a you try. Which one, and what is it about its graph that makes that happen?