← All courses  ›  Calculus Refresher  ›  Limits  ›  Introduction (Pretest)  ›  Q12

Q12 · General difference quotient

The definition of the derivative, written out in full.

Pretest Q12: find and simplify the general difference quotient for f(x) = x³ + 2x
Answer: $3x^2 + 3xh + h^2 + 2$  (option 2 of 4)

1. Intuition — what is the "general difference quotient"?

The difference quotient is the formula for the secant slope of a function between two points, in full generality. The formula you've seen since Q1:

$$\frac{f(b) - f(a)}{b - a}$$

The "general" version uses letters instead of specific numbers: it asks the question, "for an arbitrary starting point $x$ and a step $h$, what's the slope of the secant from $(x, f(x))$ to $(x+h, f(x+h))$?"

$$\frac{f(x+h) - f(x)}{(x+h) - x} = \frac{f(x+h) - f(x)}{h}$$

The denominator simplifies to $h$ because the two points are $h$ apart. The whole thing is a formula in two variables: $x$ (where you start) and $h$ (how far you step). It's the slope of the secant line in general — pick any $x$ and any $h$, this formula gives you the slope.

🌉 The Q1 ↔ Q7 ↔ Q12 ↔ Q6 chain — the heart of calculus

Q1, Q7, and Q12 are the same question with increasing generality. Q6 is what you get by taking the limit.

Question Function Formula Granularity
Q1 $f(x) = x^2$ $\frac{f(3) - f(-1)}{3 - (-1)} = \frac{9 - 1}{4} = 2$ One specific interval, one specific function
Q7 $g(x) = -x^3 + 1$ $\frac{g(2) - g(-1)}{2 - (-1)} = -3$ One specific interval, harder function
Q12 (this one) $f(x) = x^3 + 2x$ $\frac{f(x+h) - f(x)}{h}$ in closed form Any interval, any function — symbolic answer
Q6 (the limit) any $f$ $f'(a) = \lim_{h \to 0} \frac{f(a+h) - f(a)}{h}$ Two points collide → instantaneous rate

Master Q12 and you've mastered the heart of differential calculus. Take $\lim_{h \to 0}$ of Q12's answer and you have the derivative definition. Take Q6's $f'(-3)$ with a specific $f$ and you have what Q12 would have given you in the limit.

2. The recipe — five steps, every time

  1. Compute $f(x+h)$ by substituting $x+h$ for every $x$ in the formula.
  2. Expand everything — no shortcuts, expand each $(x+h)^n$ via the binomial theorem.
  3. Subtract $f(x)$.
  4. Factor out $h$ from the numerator (this is the only "trick").
  5. Cancel $h$ against the denominator $h$.

The recipe is mechanical. The only thing you have to know cold is the binomial theorem for $(x+h)^n$ — and for this problem, $n = 3$ and $n = 1$ only.

3. Worked solution — step by step

Step 1: Compute $f(x+h)$

Replace every $x$ in $f(x) = x^3 + 2x$ with $(x+h)$:

$$f(x+h) = (x+h)^3 + 2(x+h)$$

Step 2: Expand

$(x+h)^3 = x^3 + 3x^2h + 3xh^2 + h^3$ (binomial theorem)

$2(x+h) = 2x + 2h$

So $f(x+h) = x^3 + 3x^2h + 3xh^2 + h^3 + 2x + 2h$

Step 3: Subtract $f(x)$

$$f(x+h) - f(x) = \left(x^3 + 3x^2h + 3xh^2 + h^3 + 2x + 2h\right) - \left(x^3 + 2x\right)$$

The $x^3$ cancels. The $2x$ cancels. What's left:

$$= 3x^2h + 3xh^2 + h^3 + 2h$$

Step 4: Factor out $h$

Every term has at least one $h$ in it (this is by design — that's why the formula is structured the way it is):

$$= h\left(3x^2 + 3xh + h^2 + 2\right)$$

Step 5: Cancel $h$ against the denominator

$$\frac{f(x+h) - f(x)}{h} = \frac{h\left(3x^2 + 3xh + h^2 + 2\right)}{h} = 3x^2 + 3xh + h^2 + 2$$

4. The answer

$$\boxed{\frac{f(x+h) - f(x)}{h} = 3x^2 + 3xh + h^2 + 2}$$

This is option 2. It's a function of both $x$ (where you started) and $h$ (how far you stepped). Plug in any specific $x$ and $h$ to get the slope of the secant line between $(x, f(x))$ and $(x+h, f(x+h))$.

5. Sanity check — does it match Q1 and Q7?

The general difference quotient for $f(x) = x^2$ is $\frac{(x+h)^2 - x^2}{h} = \frac{2xh + h^2}{h} = 2x + h$. Plug in $x = -1$ and $h = 4$ (to get from $-1$ to $3$): $2(-1) + 4 = 2$. That matches Q1's answer. ✓

For $f(x) = x^2$ the secant slope at $x = -1$ over a step of $h = 4$ is $2$. The recipe generalizes.

6. The Q6 connection — the limit is the derivative

The derivative of $f$ at $x$ is defined as:

$$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$

So the derivative is the limit of Q12's answer as $h \to 0$. Let's take it:

$$f'(x) = \lim_{h \to 0} \left(3x^2 + 3xh + h^2 + 2\right) = 3x^2 + 3x \cdot 0 + 0^2 + 2 = 3x^2 + 2$$

And that matches the power rule: $\frac{d}{dx}(x^3 + 2x) = 3x^2 + 2$. ✓

This is the proof of the power rule for the $x^3 + 2x$ case. The same procedure proves the power rule for $x^n$ in general. The reason the power rule works is that the limit of the difference quotient always collapses the $h$-dependent terms to zero.

7. Why the other three options are traps

Option Answer What went wrong
1 $3x^2 + 3x + h + 2$ Forgot to expand $(x+h)^2$ correctly — kept $3x$ instead of $3xh$ for the middle term.
2 ✓ $3x^2 + 3xh + h^2 + 2$ The correct answer. Notice $3xh$ and $h^2$ — the $h$-dependent terms that vanish in the limit.
3 $3x^2 + 2$ This is the derivative, not the difference quotient. Took the limit too early.
4 $h^2 + 2$ Only kept the highest-order $h$ term from the numerator. Lost the $3x^2h$ and $3xh^2$ terms.

8. Common traps

Trap 1: forgetting the binomial theorem. $(x+h)^3 \neq x^3 + h^3$. You need all four terms: $x^3 + 3x^2h + 3xh^2 + h^3$. Forgetting any of the middle two is the most common error.
Trap 2: not factoring out $h$. After subtracting $f(x)$, every term must contain an $h$ — if you see a term without $h$, something went wrong. The whole point is to cancel against the $h$ in the denominator; if the $h$ doesn't factor out cleanly, you can't cancel.
Trap 3: taking the limit too early. Option 3 ($3x^2 + 2$) is the derivative, not the difference quotient. The question asks for the difference quotient — leave the $h$ in. Take the limit only when the question asks for the derivative.
Trap 4: confusing $h$ with a small number. $h$ is a variable. The answer should have both $x$ and $h$ in it. The "step" $h$ is whatever you choose — it can be 0.1 or 5 or 100. The formula is valid for any $h \neq 0$.
Why this matters in data science: the difference quotient IS the derivative is the slope is the gradient. The chain of thought — "slope between two points, generalized, in the limit, instantaneous" — is the foundation of gradient descent, backpropagation, and the entire optimization toolkit of ML. Every time a model updates its weights with $\theta := \theta - \eta \nabla L$, it's using the instantaneous rate of change of the loss with respect to the parameters — Q12's formula, in the limit. Numerical differentiation (finite differences) is Q12 with a small but nonzero $h$ — the same recipe, just before the limit. The difference quotient isn't a calc I exercise; it's the engine room.

9. Check your understanding

Mini-question. Find and simplify the general difference quotient for $g(x) = x^2 + 5$.

Show answer

$g(x+h) = (x+h)^2 + 5 = x^2 + 2xh + h^2 + 5$.
$g(x+h) - g(x) = 2xh + h^2 = h(2x + h)$.
$\frac{g(x+h) - g(x)}{h} = 2x + h$.

Note: no $h^2$ term in the simplified answer (it got absorbed). The derivative $\lim_{h \to 0} = 2x$ — matches the power rule.

10. Practice problems

  1. Find the general difference quotient for $f(x) = 4x^2 - 3x$.
    Show answer $f(x+h) = 4(x+h)^2 - 3(x+h) = 4x^2 + 8xh + 4h^2 - 3x - 3h$.
    $f(x+h) - f(x) = 8xh + 4h^2 - 3h = h(8x + 4h - 3)$.
    Difference quotient: $8x + 4h - 3$.
    Derivative (limit): $8x - 3$ — matches the power rule.
  2. Conceptual. Why does every term in the difference quotient numerator have an $h$ in it? (Hint: think about what $f(x+h) - f(x)$ means geometrically.)
    Show answer $f(x+h) - f(x)$ is the change in $f$ as $x$ changes by $h$. As $h \to 0$, the change shrinks toward 0 (assuming $f$ is continuous). So the numerator is "small" — it scales with $h$ in some sense. The denominator is exactly $h$. The ratio is a finite slope, but each individual piece of the numerator is proportional to $h$. The factoring-out step is exactly the algebraic reflection of this geometric fact.
  3. Connection to Q6. The difference quotient for $f(x) = -2x^2$ (Q6's function) is $\frac{f(x+h) - f(x)}{h} = -4x - 2h$. Verify by taking the limit as $h \to 0$ that this gives Q6's answer.
    Show answer $\lim_{h \to 0}(-4x - 2h) = -4x$. At $x = -3$: $-4(-3) = 12$. That matches Q6's $f'(-3) = 12$. ✓

11. Takeaways

© Data Science Tutor · datascience.aidalee.com