Lesson 14 of 15

Fundamental Theorem of Calculus

Fundamental Theorem of Calculus

The FTC connects differentiation and integration -- the two central operations of calculus.

Part 1

If (f) is continuous on ([a, b]) and (F(x) = \int_a^x f(t),dt), then (F) is differentiable and (F'(x) = f(x)).

Part 2

If (f) is continuous on ([a, b]) and (F) is any antiderivative of (f), then:

abf(x)dx=F(b)F(a)\int_a^b f(x)\,dx = F(b) - F(a)

Numerical Verification

We can verify the FTC numerically:

  1. Compute (F(x) = \int_a^x f(t),dt) using numerical integration
  2. Compute (F'(x)) using numerical differentiation
  3. Check that (F'(x) \approx f(x))

Simpson's Rule

For more accurate numerical integration, use Simpson's rule:

abf(x)dxΔx3[f(x0)+4f(x1)+2f(x2)+4f(x3)++f(xn)]\int_a^b f(x)\,dx \approx \frac{\Delta x}{3} \left[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + f(x_n)\right]

where (n) must be even.

Your Task

Implement:

  1. integrate(f, a, b, n) -- Simpson's rule with (n) subintervals ((n) must be even)
  2. antiderivative_at(f, a, x, n) -- computes (F(x) = \int_a^x f(t),dt) using Simpson's rule
  3. verify_ftc(f, a, x, h, n) -- checks that the numerical derivative of (F(x)) approximately equals (f(x)) (within 0.001). Uses (F'(x) \approx (F(x+h) - F(x-h)) / (2h)).
Pyodide loading...
Loading...
Click "Run" to execute your code.