Statistics For Programmers - Bonus Content: Expressing a Taylor Polynomial in Code

A Taylor polynomial is generally used when approximating functions. They are especially useful when the true or exact form of the function is complex or difficult to work with.

By expressing a function as a Taylor series, it's possible to simplify calculations and gain insights into its behavior, particularly around the point where the series is centered. Expressing this as code is pretty interesting when broken down into its components. Let's take an example to see this in action:

\[ P_n(x) = \sum_{n=0}^\infty \frac{f^{(n)}a}{n!} \times (x - a)^n \]


  • \( P_n(x) \) is the nth Taylor polynomial centered at a.
  • \( a \) is the point at which the polynomial is centered.
  • \( f^{(n)}a \) is the nth derivative of f evaluated at a.

This post is for subscribers only

Already have an account? Sign in.

Subscribe to Another Dev's Two Cents

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.