Lesson 10 of 18
Taylor Polynomial
Taylor Polynomial
The Taylor polynomial of degree approximates near point :
P_n(x) = sum_{k=0}^n rac{f^{(k)}(a)}{k!} cdot (x-a)^k
Where is the -th derivative of at .
Building Intuition
- — constant (matches value at )
- — linear (also matches slope)
- — also matches curvature
- Each higher term matches one more derivative at
Exact for Polynomials
A degree- Taylor polynomial reproduces any degree- polynomial exactly:
at :
P_2(x) = f(0) + f'(0)x + rac{f''(0)}{2!} x^2 = 0 + 0 + rac{2}{2} x^2 = x^2 checkmark
Numerical nth Derivative
Use recursive central differences:
f^(0)(x) = f(x)
f^(n)(x) ≈ (f^(n-1)(x+h) - f^(n-1)(x-h)) / (2h)
This is accurate to at each level. Keep and for best results.
Your Task
Implement double taylor_poly(double (*f)(double), double a, double x, int n, double h).
Use recursive nth_deriv and a loop-based factorial. Helper stubs are provided.
TCC compiler loading...
Loading...
Click "Run" to execute your code.