Why Check a Derivative Numerically?
A derivative rule can look plausible and still contain a sign, coefficient, or algebra error. A calculator can provide a useful independent check: estimate the derivative of the original function at selected inputs, then compare those estimates with the proposed derivative formula.
This check is especially useful when a rule has several terms or when a suspected error appears only in part of the domain. Testing more than one input can help locate a problem. But numerical checking has a limit: a calculator estimates the derivative using a finite change in the input, so its result is not automatically the exact derivative.
The Symmetric Difference-Quotient Estimate
Suppose \(f\) is defined near an input \(x\). For a nonzero step \(h\) such that both \(x-h\) and \(x+h\) are in the domain, the symmetric difference quotient is
A calculator evaluates the two function values and the quotient. If \(f\) is differentiable at \(x\), these estimates approach \(f'(x)\) as \(h\) approaches zero. The value for a particular nonzero \(h\), however, is generally only an estimate.
Why the Estimate Approaches the Derivative
The reason follows directly from the definition of the derivative. When \(f\) is differentiable at \(x\), the forward difference quotient and the backward difference quotient each approach \(f'(x)\) as \(h\to0\). The symmetric quotient is their average:
For the backward term, the usual derivative quotient with increment \(-h\) is
Thus both terms inside the average approach \(f'(x)\). The limit of their average is therefore \(f'(x)\). This justifies using the symmetric quotient as a numerical check when \(h\) is small and the function behaves regularly near \(x\). It does not say that any one finite-step estimate equals the derivative exactly.
A Practical Checking Process
Choose \(x\) and \(h\) so that \(x-h\) and \(x+h\) are valid inputs to the original function.
Test several inputs, including one near a suspected error. Avoid relying on a point where different formulas happen to give the same value.
Evaluate \(f(x+h)\) and \(f(x-h)\), then calculate their difference divided by \(2h\).
Compare the two values at a consistent precision. If they differ substantially, repeat the check with a smaller step and inspect the setup.
Using the original function for the estimate is important. If you use the proposed derivative formula to generate the estimate, you are not checking it independently.
Worked Example: A Finite Step Can Mislead
Worked Example: A Cubic Function at One Input
Let \(f(x)=x^3\). Its derivative is \(f'(x)=3x^2\), so \(f'(1)=3\). First test the symmetric estimate with the relatively large step \(h=1\):
The estimate is \(4\), not \(3\). That difference does not show that the derivative rule is wrong: \(h=1\) is not a small step here. Reduce the step to \(h=0.1\):
With \(h=0.01\), the estimate is
The estimates move closer to \(3\) as the step decreases. The exact derivative value \(3\) is the check at this input; the finite-step estimates illustrate why a mismatch from one choice of \(h\) is not by itself a disproof.
Check: Substituting \(x=1\) into \(f'(x)=3x^2\) gives \(3(1)^2=3\), consistent with the estimates for the smaller steps.
Worked Example: Checking a Rational Derivative
Worked Example: Compare at Three Domain Points
Consider \(f(x)=\frac{1}{x^2+1}\), and check the proposed derivative \(g(x)=-\frac{2x}{(x^2+1)^2}\). The function is defined for every real \(x\). Use \(h=0.01\), so the calculator estimate is \(\frac{f(x+0.01)-f(x-0.01)}{0.02}\).
At \(x=0.5\), evaluate both function values:
Therefore, the symmetric estimate is
The proposed formula gives
These values are close. Repeat at \(x=1\):
Now include a point near \(x=1\), where a suspected error might occur, and use \(x=1.01\):
The last two values agree when rounded to five decimal places: both are \(-0.49500\). This comparison supports the proposed formula at these test points; it does not establish the rule for every input.
Check: Differentiating \((x^2+1)^{-1}\) gives \(-(x^2+1)^{-2}(2x)=-\frac{2x}{(x^2+1)^2}\), the proposed expression. Substitution at \(x=1.01\) gives \(-2.02/(2.0201)^2\), matching the numerical estimate to the displayed precision.
Worked Example: Testing Near a Suspected Typo
Worked Example: A Coefficient Error in a Candidate
Let \(f(x)=x^3-2x\). Suppose a proposed derivative is \(q(x)=3x^2-1\). The coefficient of the constant term is suspected, so test several inputs, including \(x=1.01\), near \(1\). Use \(h=0.01\).
At \(x=0.5\), the function values are
Thus
The proposed value is \(q(0.5)=3(0.5)^2-1=0.75-1=-0.25\), a substantial difference. At \(x=1\):
But \(q(1)=3-1=2\), again substantially different. Finally, at \(x=1.01\), the two inputs are \(1.02\) and \(1\):
The candidate gives \(q(1.01)=3(1.0201)-1=3.0603-1=2.0603\), again about \(1\) larger than the numerical estimate. The repeated substantial discrepancy, including at the nearby point, is strong evidence that the proposed rule is wrong. Here the exact derivative is \(3x^2-2\), which confirms that the candidate's constant term should be \(-2\), not \(-1\).
Check: At \(x=1.01\), the exact derivative is \(3(1.01)^2-2=3(1.0201)-2=3.0603-2=1.0603\). The estimate \(1.0604\) differs by \(0.0001\), as expected for a finite step, while the candidate value \(2.0603\) differs by approximately \(1\).
Common Pitfall: Treating an Estimate as Exact
A common error is to regard any numerical mismatch as proof that a derivative formula is false. The cubic example shows why this is unsafe: at \(x=1\), the exact derivative is \(3\), while the symmetric estimate with \(h=1\) is \(4\). The derivative rule is still correct. A large step can create a noticeable difference even when the proposed derivative is right.
The opposite mistake is also possible: treating a close match at a few points as proof. A finite set of test points cannot establish that two functions agree throughout a domain. Use numerical checks to find possible errors, then rely on mathematical justification to establish a rule.
Choosing Points and Interpreting Results
Good test points are valid inputs that probe different parts of the expression. If a suspected mistake involves a sign or constant, choose points where that term has a visible effect. Include an input near the suspected location, as well as other convenient domain points. Avoid choosing only special values where the disputed terms vanish or happen to agree.
Keep the step size and rounding in mind. A smaller \(h\) often makes the difference quotient more representative of local change, but calculator arithmetic can also become sensitive when subtracting nearly equal function values. Record enough digits during intermediate calculations, then round the final comparison consistently. If two results differ only in the last displayed digit, that is not the same as a substantial discrepancy.
Numerical checking is valuable because it can catch errors before they affect later work. It is most reliable as a diagnostic process: calculate independently from the original function, test several inputs, investigate mismatches, and distinguish evidence from proof.
Check Your Understanding
Answer the questions using the definitions and examples above.
- For \(f(x)=x^3\) at \(x=1\), why does the symmetric estimate with \(h=1\) fail to equal the exact derivative?
- What domain condition must hold for the symmetric difference quotient at \(x\) with step \(h\)?
- Why does a close numerical match at several points not prove a derivative rule on an entire interval?
- A proposed derivative differs substantially from an estimate at one point. What checks should you perform before deciding that the rule is wrong?
- Why is it useful to test near a location where a sign or coefficient error is suspected?