The average rate of change of \(y\) wih respect to \(x\), as \(x\) changes from \(x_1\) to \(x_2\), is the ratio of the change in output to the change in input:

\[A(x) = \frac{f(x_2) - f(x_1)}{x_2 - x_1}\]

where \(x_2 \neq x_1\). The average rate of change is the secant line passing through two points. If we generalize this idea we arrive at the different quotient, an average rate of change over any interval of a function.

\[\frac{f(x + h) - f(x)}{h}\]

where \(h \neq 0\). The difference quotient is equal to the slope or secant line from \((x, f(x))\) to \((x + h, f(x + h))\).

Let’s look at a textbook problem.

Compound Interest

The amount of money, \(A(t)\), in a savings account that pays 6% interest, compounded quarterly for \(t\) years, when an initial investment of $2000 is made, is given by \(A(t) = 2000(1.1015)^{4t}\). Find \(A(3)\). Find \(A(5)\). Find \(A(5) - A(3)\). Find \(\frac{A(5) - A(3)}{5 - 3}\), and interpret this result.

import numpy as np
import matplotlib.pyplot as plt

def difference_quotient(f, x, h):
  return (f(x + h) - f(x)) / h
  
def func(t):
  return 2000 * (1.1015) ** (4* t)
  
func(3)
## 6380.342808691802
func(5)
## 13826.747291189786
func(5) - func(3)
## 7446.404482497984
difference_quotient(func, 3, 2)
## 3723.202241248992
x_values = range(0, 8)
y_values = [func(t) for t in range(0, 8)]
color = ["red" if y == func(3) or y == func(5) else "blue" for y in y_values]

fig, ax = plt.subplots()
ax.scatter(x_values, y_values, c=color)

The difference quotient represents the average rate of change between the third year, \(A(3)\), and the fifth year, \(A(5)\), which are two units apart.