Lesson 2 of 18
The Derivative
The Derivative
The derivative of at is the instantaneous rate of change — the slope of the tangent line at that point:
Central Difference Formula
The forward difference has error . The central difference is more accurate — error :
This is what you should implement. With h = 1e-6, results match analytic derivatives to 9+ significant figures.
Analytic Derivatives
For reference, the exact rules you can verify numerically:
| Function | Derivative |
|---|---|
| (power rule) | |
| (chain rule) |
Verification
For :
- Analytic:
- Central difference: ✓ (exact, regardless of )
Your Task
Implement double derivative(double (*f)(double), double x, double h) using the central difference formula.
TCC compiler loading...
Loading...
Click "Run" to execute your code.