Practical Labs/Lab: Taylor Expansion and Local Approximation
Level 2 · calculus
Lab: Taylor Expansion and Local Approximation
Build a minimal, verifiable implementation that demonstrates Taylor Expansion and Local Approximation. Connect the code to the governing equation, inspect its output numerically, and explain one failure case.
Mathematical basis
For Taylor Expansion and Local Approximation, verify and estimate the truncation error .
Instructions
- 01Read section 7 of the Taylor Expansion and Local Approximation learning page and write its governing equation on paper.
- 02Implement the core operation in JAX / NumPy on the Rosenbrock function and toy curves. Do not call a library function that solves the whole task.
- 03Verify the implementation on a hand-computed three-element or 3×3 example before scaling up.
- 04Run the experiment with the step size h and record gradient-check error.
- 05Inspect the output, identify one discrepancy with the theory, and write a one-paragraph explanation.
Starter code
import numpy as np
def central(f, x, h=1e-4):
return (f(x + h) - f(x - h)) / (2*h)
f = lambda x: x**2 + 3*x
d = central(f, 2.0)
assert abs(d - 7.0) < 1e-6, d
print(d)