Skip to main content

3.2 Taylor Series and Taylor Polynomial

The Taylor series is a representation of a function $f$ as an infinite sum of  terms. These terms are determined using derivatives of $f$ evaluated at $x_0$.

Taylor Polynomial

The Taylor Polynomial of degree $n$ of $f : \mathbb{R} \mapsto \mathbb{R}$ at $x_0$ is defined as

$T_n(x) = \sum_{k=0}^{n} \frac{f^{(k)}(x_0)}{k!} (x-x_0)^k$

where $f^{(k)}(x_0)$ is the $k^{th}$ derivative of $f$ at $x_0$ (which we assume exists) and $\frac{f^{(k)}(x_0)}{k!}$  are the coefficients of the polynomial.

Taylor Series

For a smooth function $f \in C^\infty, f: \mathbb{R} \mapsto \mathbb{R}$, the Taylor series of $f$ at $x_0$ is defined as

$T_\infty(x) = \sum_{k=0}^{\infty} \frac{f^{(k)}(x_0)}{k!} (x-x_0)^k$

At $x_0=0$, we obtain the Maclaurin series as a special instance of the Taylor series.If $f(x)=T_\infty(x)$, then $f$ is called analytic.

In general, a Taylor polynomial of degree $n$ is an approximation of a function, which does not need to be a polynomial. The Taylor polynomial is similar to $f$ in a neighborhood around $x_0$. However, a Taylor polynomial of degree $n$ is an exact representation of a polynomial $f$ of degree $k <=n$ since all derivatives $f(i), i > k $ vanish.
Example Taylor Polynomial:
Lets consider a function $f(x)=x^4$
We will Find the Taylor Polynomial $T_6$, evaluated at $x_0=1$

$f(x)=x^4=f(1)=1$
$f'(x)=4x^3=f'(1)=4$
$f''(x)=12x^2=f''(1)=12$
$f^3(x)=24x^1=f^3(1)=24$
$f^4(x)=24=f^4(1)=24$
$f^5(x)=0=f^5(1)=0$
$f^6(x)=0=f^6(1)=0$

Therefore the Taylor polynomial is

$T_n(x) = \sum_{k=0}^{n} \frac{f^{(k)}(x_0)}{k!} (x-x_0)^k$
              $=1+ \frac{4}{1!}(x-1)+ \frac{12}{2!}(x-1)^2+\frac{24}{3!}(x-1)^3+\frac{24}{4!}(x-1)^4+\frac{0}{5!}(x-1)^5+\frac{0}{1!}(x-1)^6$
$=1+4(x-1)+6(x^2+1-2x)+4(x^3-3x^2+3x-1)+(x^4-4x^3+6x^2-4x+1)$
$=1+4x-4+6x^2+6-12x+4x^3-12x^2+12x-4+x^4-4x^3+6x^2-4x+1$
$=x^4$
ie; we obtain the exact representation of the original function.

Example Taylor Series:
Consider the function given by
$f(x)=sin(x)+cos(x) \in C ^\infty$

Lets find a Taylor series expansion of $f$ at $x_0=0$, which is the Maclaurian series expansion of $f$.

$f(x)=sin(x)+cos(x)=f(0)=1$
$f'(x)=cos(x)-sin(x)=f'(0)=1$
$f''(x)=-sin(x)-cos(x)=f''(0)=-1$
$f^3(x)=-cos(x)+sin(x)=f^3(0)=-1$
$f^4(x)=sin(x)+cos(x)=f^4(0)=1$
$ \vdots$

The Taylor series expansion of $f$ at $x_0=0$ is given by

$T_\infty(x) = \sum_{k=0}^{\infty} \frac{f^{(k)}(x_0)}{k!} (x-x_0)^k$

 $=1+x-\frac{x^2}{2!}-\frac{x^3}{3!}+\frac{x^4}{4!}+\frac{x^5}{5!}- \ldots$
$=1-\frac{x^2}{2!}+\frac{x^4}{4!}-+\frac{x^6}{6!}+x-\frac{x^3}{3!}+\frac{x^5}{5!}$
 $=\sum_{k=0}^{\infty} (-1)^k \frac{1}{(2k)!}x^{2k}+\sum_{k=0}^{\infty} (-1)^k \frac{1}{(2k+1)!)}x^{2k+1}$
                     $=cos(x)+sin(x)$
Here we used the power series expansion
$cos(x)=\sum_{k=0}^{\infty} (-1)^k \frac{1}{(2k)!}x^{2k}$
$sin(x)=\sum_{k=0}^{\infty} (-1)^k \frac{1}{(2k+1)!)}x^{2k+1}$

Remark: A Taylor series is a special case of a power series
$f(x)=\sum_{k=0}^{\infty}a_k(x-c)^k$

Where $a_k$ are coefficients and $c$ is a constant, which has the special form.

Example:
Compute the Taylor polynomial $T_n,n=0,\ldots,5$ of $f(x)=sin(x)+cos(x)$ at $x_0=0$
$f^0(0)=sin(0)+cos(0)=1$
$f^1(0)=cos(0)-sin(0)=1$
$f^2(0)=-sin(0)-cos(0)= -1$
$f^3(0)=-cos(0)+sin(0)= -1$
$f^4(0)=sin(0)+cos(0)= 1$
$f^5(0)=cos(0)-sin(0)= 1$
Taylor polynomial at $x_0=0$ is
$T_n(x)=\sum_{k=0}^{n}\frac{f^k(0)}{k!} x^k$
$T_0(x)=\frac{f^0(0)}{0!}x^0=\frac{1}{1}.1=1$
$T_1(x)=T_0(x)+\frac{f^1(0)}{1!}x^1=1+1.x=1+x$
$T_2(x)=T_1(x)+\frac{f^2(0)}{2!}x^2=1+x-\frac{1}{2!}x^2$
$T_3(x)=T_2(x)+\frac{f^3(0)}{3!}x^3=1+x-\frac{1}{2!}x^2-\frac{1}{3!}x^3$
$T_4(x)=T_3(x)+\frac{f^4(0)}{4!}x^4=1+x-\frac{1}{2!}x^2-\frac{1}{3!}x^3+\frac{1}{4!}x^4$
$T_5(x)=T_4(x)+\frac{f^5(0)}{5!}x^5=1+x-\frac{1}{2!}x^2-\frac{1}{3!}x^3+\frac{1}{4!}x^4+\frac{1}{5!}x^5$





Find the nth Maclaurin polynomial for $f(x)=e^x, n=5$ (University question)

The Maclaurin polynomial
$f(x)=\sum_{k=0}^n f^k(0) x^k/k!$
$f^0(0)=e^x=e^0=1$
$f^1(0)=e^x=e^0=1$
$f^2(0)=e^x=e^0=1$
$f^3(0)=e^x=e^0=1$
$f^4(0)=e^x=e^0=1$
$f^5(0)=e^x=e^0=1$
$f(x)=1.x^0/0!+1.x^1/1!+1.x^2/2!+1.x^3/3!+1.x^4/4!+1.x^5/5!$
$f(x)=1+x+x^2/2!+x^3/3!+x^4/4!+x^5/5!$

Comments

Popular posts from this blog

Mathematics for Machine Learning- CST 284 - KTU Minor Notes - Dr Binu V P

  Introduction About Me Syllabus Course Outcomes and Model Question Paper University Question Papers and Evaluation Scheme -Mathematics for Machine learning CST 284 KTU Overview of Machine Learning What is Machine Learning (video) Learn the Seven Steps in Machine Learning (video) Linear Algebra in Machine Learning Module I- Linear Algebra 1.Geometry of Linear Equations (video-Gilbert Strang) 2.Elimination with Matrices (video-Gilbert Strang) 3.Solving System of equations using Gauss Elimination Method 4.Row Echelon form and Reduced Row Echelon Form -Python Code 5.Solving system of equations Python code 6. Practice problems Gauss Elimination ( contact) 7.Finding Inverse using Gauss Jordan Elimination  (video) 8.Finding Inverse using Gauss Jordan Elimination-Python code Vectors in Machine Learning- Basics 9.Vector spaces and sub spaces 10.Linear Independence 11.Linear Independence, Basis and Dimension (video) 12.Generating set basis and span 13.Rank of a Matrix 14.Linear Mapping...

Vectors in Machine Learning

As data scientists we work with data in various formats such as text images and numerical values We often use vectors to represent data in a structured and efficient manner especially in machine learning applications In this blog post we will explore what vectors are in terms of machine learning their significance and how they are used What is a Vector? In mathematics, a vector is a mathematical object that has both magnitude and direction. In machine learning, a vector is a mathematical representation of a set of numerical values. Vectors are usually represented as arrays or lists of numbers, and each number in the list represents a specific feature or attribute of the data. For example, suppose we have a dataset of houses, and we want to predict their prices based on their features such as the number of bedrooms, the size of the house, and the location. We can represent each house as a vector, where each element of the vector represents a specific feature of the house, such as the nu...

2.14 Singular Value Decomposition

The Singular Value Decomposition ( SVD) of a matrix is a central matrix decomposition method in linear algebra.It can be applied to all matrices,not only to square matrices and it always exists.It has been referred to as the 'fundamental theorem of linear algebra'( strang 1993). SVD Theorem: Let $A^{m \times n}$ be a rectangular matrix of rank $r \in [0,min(m,n)]$. The SVD of A is a decomposition of the form. $A= U \Sigma V^T $ with an orthogonal matrix $U \in \mathbb{R}^{m \times m}$ with column vectors $u_i, i=1,\ldots,m$ and an orthogonal matrix $V \in \mathbb{R}^{n \times n}$ with column vectors $v_j, j=1,\ldots,n$.Moreover, $\Sigma$ is an $m \times n$ matrix with $\sum_{ii} = \sigma \ge 0$ and $\sigma_{ij}=0, i \ne j$. The diagonal entries $\Sigma_i=1,\ldots,r$ of $\sigma$ are called singular values . $u_i$ are called left singular vectors , and $v_j$ are called right singular vectors .By convention singular values are ordered ie; $\sigma_1 \ge \sigma_2 \ldots \sigma_r \...