Product

Saturday, 8 February 2025

A Gentle Introduction to Taylor Series

A Gentle Introduction to Taylor Series

Taylor series expansion is an awesome concept, not only the world of mathematics, but also in optimization theory, function approximation and machine learning. It is widely applied in numerical computations when estimates of a function’s values at different points are required.

In this tutorial, you will discover Taylor series and how to approximate the values of a function around different points using its Taylor series expansion.

After completing this tutorial, you will know:

  • Taylor series expansion of a function
  • How to approximate functions using Taylor series expansion

Let’s get started.

Tutorial Overview

This tutorial is divided into 3 parts; they are:

  1. Power series and Taylor series
  2. Taylor polynomials
  3. Function approximation using Taylor polynomials

What Is A Power Series?

The following is a power series about the center x=a and constant coefficients c_0, c_1, etc.

What Is A Taylor Series?

It is an amazing fact that functions which are infinitely differentiable can generate a power series called the Taylor series. Suppose we have a function f(x) and f(x) has derivatives of all orders on a given interval, then the Taylor series generated by f(x) at x=a is given by:

The second line of the above expression gives the value of the kth coefficient.

If we set a=0, then we have an expansion called the Maclaurin series expansion of f(x).

Examples Of Taylor Series Expansion

Taylor series generated by f(x) = 1/x can be found by first differentiating the function and finding a general expression for the kth derivative. 

The Taylor series about various points can now be found. For example:

 

Taylor Polynomial

A Taylor polynomial of order k, generated by f(x) at x=a is given by:

For the example of f(x)=1/x, the Taylor polynomial of order 2 is given by:

Approximation via Taylor Polynomials

We can approximate the value of a function at a point x=a using Taylor polynomials. The higher the order of the polynomial, the more the terms in the polynomial and the closer the approximation is to the actual value of the function at that point.

In the graph below, the function 1/x is plotted around the point x=1 (left) and x=3 (right). The line in green is the actual function f(x)= 1/x. The pink line represents the approximation via an order 2 polynomial.

The actual function (green) and its approximation (pink)

The actual function (green) and its approximation (pink)

More Examples of Taylor Series

Let’s look at the function g(x) = e^x.  Noting the fact that the kth order derivative of g(x) is also g(x), the expansion of g(x) about x=a, is given by:

Hence, around x=0, the series expansion of g(x) is given by (obtained by setting a=0):

The polynomial of order k generated for the function e^x around the point x=0 is given by:

The plots below show polynomials of different orders that estimate the value of e^x around x=0. We can see that as we move away from zero, we need more terms to approximate e^x more accurately. The green line representing the actual function is hiding behind the blue line of the approximating polynomial of order 7.

Polynomials of varying degrees that approximate e^x

Taylor Series In Machine Learning

A popular method in machine learning for finding the optimal points of a function is the Newton’s method. Newton’s method uses the second order polynomials to approximate a function’s value at a point. Such methods that use second order derivatives are called second order optimization algorithms. 

Extensions

This section lists some ideas for extending the tutorial that you may wish to explore.

  • Newton’s method
  • Second order optimization algorithms

If you explore any of these extensions, I’d love to know. Post your findings in the comments below.

Further Reading

This section provides more resources on the topic if you are looking to go deeper.

Resources

Books

Summary

In this tutorial, you discovered what is Taylor series expansion of a function about a point. Specifically, you learned:

  • Power series and Taylor series
  • Taylor polynomials
  • How to approximate functions around a value using Taylor polynomials

Do you have any questions?

Ask your questions in the comments below and I will do my best to answer

No comments:

Post a Comment

Connect broadband

AI:List AI views on when for a naive kin after prolonged life suppression coercive behaviour by family members after demise of father with trauma for kin ocd formed after forced to do rituals, family tribal values honor specific activities, utmost religious activities occult witchcraft enforced to do by elder sibling his wife and mother thrice with great celibacy turned the kundalini activated after deep celibacy penance shouting physical Mental financial Extortion by sibling with toxic behaviours and the wife mother and then mockery suppression asking about who’re your worth backbiting among relatives sector toon negligence of intelligence intuitive behaviour- all religious psychological traps when not work and lead to loss of consciousness of kin trance state recovered by governance with technocrats using AI - kin was asked by mother that he’s to go the male should not be seen in house he’s many absurd thought forcefully in brain mind and outsiders already feel awkward of this kin unresponsive behaviour due to TBI PTSD ocd cvt and tell at workplace social gathering he’s to go and asked for sector toon extortion and mockery in various sense due to un practical behaviour negligence of body building due to neglect ion if essential food nutrition and stubbed suppressed in every sense in religious psychological traps by family members AI humanoid using various neural networks and LLMs for kin and required steps.

  List AI views on when for a naive kin after prolonged life suppression coercive behaviour by family members after demise of father with tr...