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 Question Paper July 2021 and evaluation scheme Question Paper June 2022 and evaluation scheme 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 and Matri

1.1 Solving system of equations using Gauss Elimination Method

Elementary Transformations Key to solving a system of linear equations are elementary transformations that keep the solution set the same, but that transform the equation system into a simpler form: Exchange of two equations (rows in the matrix representing the system of equations) Multiplication of an equation (row) with a constant  Addition of two equations (rows) Add a scalar multiple of one row to the other. Row Echelon Form A matrix is in row-echelon form if All rows that contain only zeros are at the bottom of the matrix; correspondingly,all rows that contain at least one nonzero element are on top of rows that contain only zeros. Looking at nonzero rows only, the first nonzero number from the left pivot (also called the pivot or the leading coefficient) is always strictly to the right of the  pivot of the row above it. The row-echelon form is where the leading (first non-zero) entry of each row has only zeroes below it. These leading entries are called pivots Example: $\begin

4.3 Sum Rule, Product Rule, and Bayes’ Theorem

 We think of probability theory as an extension to logical reasoning Probabilistic modeling  provides a principled foundation for designing machine learning methods. Once we have defined probability distributions corresponding to the uncertainties of the data and our problem, it turns out that there are only two fundamental rules, the sum rule and the product rule. Let $p(x,y)$ is the joint distribution of the two random variables $x, y$. The distributions $p(x)$ and $p(y)$ are the corresponding marginal distributions, and $p(y |x)$ is the conditional distribution of $y$ given $x$. Sum Rule The addition rule states the probability of two events is the sum of the probability that either will happen minus the probability that both will happen. The addition rule is: $P(A∪B)=P(A)+P(B)−P(A∩B)$ Suppose $A$ and $B$ are disjoint, their intersection is empty. Then the probability of their intersection is zero. In symbols:  $P(A∩B)=0$  The addition law then simplifies to: $P(A∪B)=P(A)+P(B)$  wh