Numerical Analysis

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 f(x)f(x)
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 f(x)f(x)
- - - 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: f(x)f(x) = cos(x), x = 0.524

f(0.524)f(0.534)f(0.514)0.02f'(0.524) \approx \frac{f(0.534) - f(0.514)}{0.02}

Problem 2: f(x)f(x) = x^2, x = 2.000

f(2.000)f(2.010)f(1.990)0.02f'(2.000) \approx \frac{f(2.010) - f(1.990)}{0.02}

Problem 3: f(x)f(x) = x^3, x = 1.500

f(1.500)f(1.510)f(1.490)0.02f'(1.500) \approx \frac{f(1.510) - f(1.490)}{0.02}

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)