Numerical Differentiation & Integration
Approximate derivatives using difference quotients and integrals using trapezoidal and Simpson's rules.
Numerical Differentiation
Approximate the derivative f'(x) using finite difference formulas. The exact derivative is the limit as h → 0.
Function
Point x = 0.7854
Step size h = 0.1000
Exact f'(x): 0.707107
Forward:
0.670603 ε = 0.03650381
Backward:
0.741255 ε = 0.03414796
Central:
0.705929 ε = 0.00117792
━━ Function
- - - Exact tangent (green)
━━ Forward difference secant
━━ Backward difference secant
━━ Central difference secant
Practice Problems
Use central difference with h = 0.01 to approximate f'(x). Enter your answer to 3 decimal places.
Problem 1: = cos(x), x = 0.524
Problem 2: = x^2, x = 2.000
Problem 3: = x^3, x = 1.500
Implementation
"hljs-comment">// Forward difference
f'(x) ≈ (f(x + h) - f(x)) / h
"hljs-comment">// Backward difference
f'(x) ≈ (f(x) - f(x - h)) / h
"hljs-comment">// Central difference (most accurate)
f'(x) ≈ (f(x + h) - f(x - h)) / (2h)