Taylor series by Matlab
Need Help with part b
Suppose we want the Taylor series at 0 of the function:
{\displaystyle g(x)={\frac {e^{x}}{\cos x}}.\!} g(x)={\frac
{e^{x}}{\cos x}}.\!
We have for the exponential function
{\displaystyle e^{x}=\sum _{n=0}^{\infty }{\frac
{x^{n}}{n!}}=1+x+{\frac {x^{2}}{2!}}+{\frac {x^{3}}{3!}}+{\frac
{x^{4}}{4!}}+\cdots \!} {\displaystyle e^{x}=\sum _{n=0}^{\infty
}{\frac {x^{n}}{n!}}=1+x+{\frac {x^{2}}{2!}}+{\frac
{x^{3}}{3!}}+{\frac {x^{4}}{4!}}+\cdots \!}
and, as in the first example,
{\displaystyle \cos x=1-{\frac {x^{2}}{2!}}+{\frac
{x^{4}}{4!}}-\cdots \!} {\displaystyle \cos x=1-{\frac
{x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots \!}
Assume the power series is
{\displaystyle {\frac {e^{x}}{\cos
x}}=c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+\cdots \!} {\displaystyle
{\frac {e^{x}}{\cos x}}=c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+\cdots
\!}
Then multiplication with the denominator and substitution of the
series of the cosine yields
{\displaystyle
{\begin{aligned}e^{x}&=\left(c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+\cdots
\right)\cos
x\\&=\left(c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+c_{4}x^{4}+\cdots
\right)\left(1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots
\right)\\&=c_{0}-{\frac {c_{0}}{2}}x^{2}+{\frac
{c_{0}}{4!}}x^{4}+c_{1}x-{\frac {c_{1}}{2}}x^{3}+{\frac
{c_{1}}{4!}}x^{5}+c_{2}x^{2}-{\frac {c_{2}}{2}}x^{4}+{\frac
{c_{2}}{4!}}x^{6}+c_{3}x^{3}-{\frac {c_{3}}{2}}x^{5}+{\frac
{c_{3}}{4!}}x^{7}+\cdots \end{aligned}}\!} {\displaystyle
{\begin{aligned}e^{x}&=\left(c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+\cdots
\right)\cos
x\\&=\left(c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+c_{4}x^{4}+\cdots
\right)\left(1-{\frac {x^{2}}{2!}}+{\frac {x^{4}}{4!}}-\cdots
\right)\\&=c_{0}-{\frac {c_{0}}{2}}x^{2}+{\frac
{c_{0}}{4!}}x^{4}+c_{1}x-{\frac {c_{1}}{2}}x^{3}+{\frac
{c_{1}}{4!}}x^{5}+c_{2}x^{2}-{\frac {c_{2}}{2}}x^{4}+{\frac
{c_{2}}{4!}}x^{6}+c_{3}x^{3}-{\frac {c_{3}}{2}}x^{5}+{\frac
{c_{3}}{4!}}x^{7}+\cdots \end{aligned}}\!}
Collecting the terms up to fourth order yields
{\displaystyle e^{x}=c_{0}+c_{1}x+\left(c_{2}-{\frac
{c_{0}}{2}}\right)x^{2}+\left(c_{3}-{\frac
{c_{1}}{2}}\right)x^{3}+\left(c_{4}-{\frac {c_{2}}{2}}+{\frac
{c_{0}}{4!}}\right)x^{4}+\cdots \!} {\displaystyle
e^{x}=c_{0}+c_{1}x+\left(c_{2}-{\frac
{c_{0}}{2}}\right)x^{2}+\left(c_{3}-{\frac
{c_{1}}{2}}\right)x^{3}+\left(c_{4}-{\frac {c_{2}}{2}}+{\frac
{c_{0}}{4!}}\right)x^{4}+\cdots \!}
Comparing coefficients with the above series of the exponential
function yields the desired Taylor series
{\displaystyle {\frac {e^{x}}{\cos x}}=1+x+x^{2}+{\frac
{2x^{3}}{3}}+{\frac {x^{4}}{2}}+\cdots .\!} {\displaystyle {\frac
{e^{x}}{\cos x}}=1+x+x^{2}+{\frac {2x^{3}}{3}}+{\frac
{x^{4}}{2}}+\cdots .\!}
Third example[edit]
Here we employ a method called "indirect expansion" to expand the
given function. This method uses the known Taylor expansion of the
exponential function. In order to expand (1 + x)ex as a Taylor
series in x, we use the known Taylor series of function ex:
{\displaystyle e^{x}=\sum _{n=0}^{\infty }{\frac
{x^{n}}{n!}}=1+x+{\frac {x^{2}}{2!}}+{\frac {x^{3}}{3!}}+{\frac
{x^{4}}{4!}}+\cdots .} {\displaystyle e^{x}=\sum _{n=0}^{\infty
}{\frac {x^{n}}{n!}}=1+x+{\frac {x^{2}}{2!}}+{\frac
{x^{3}}{3!}}+{\frac {x^{4}}{4!}}+\cdots .}
Thus,
{\displaystyle {\begin{aligned}(1+x)e^{x}&=e^{x}+xe^{x}=\sum
_{n=0}^{\infty }{\frac {x^{n}}{n!}}+\sum _{n=0}^{\infty }{\frac
{x^{n+1}}{n!}}=1+\sum _{n=1}^{\infty }{\frac {x^{n}}{n!}}+\sum
_{n=0}^{\infty }{\frac {x^{n+1}}{n!}}\\&=1+\sum _{n=1}^{\infty
}{\frac {x^{n}}{n!}}+\sum _{n=1}^{\infty }{\frac
{x^{n}}{(n-1)!}}=1+\sum _{n=1}^{\infty }\left({\frac
{1}{n!}}+{\frac {1}{(n-1)!}}\right)x^{n}\\&=1+\sum
_{n=1}^{\infty }{\frac {n+1}{n!}}x^{n}\\&=\sum _{n=0}^{\infty
}{\frac {n+1}{n!}}x^{n}.\end{aligned}}} {\displaystyle
{\begin{aligned}(1+x)e^{x}&=e^{x}+xe^{x}=\sum _{n=0}^{\infty
}{\frac {x^{n}}{n!}}+\sum _{n=0}^{\infty }{\frac
{x^{n+1}}{n!}}=1+\sum _{n=1}^{\infty }{\frac {x^{n}}{n!}}+\sum
_{n=0}^{\infty }{\frac {x^{n+1}}{n!}}\\&=1+\sum _{n=1}^{\infty
}{\frac {x^{n}}{n!}}+\sum _{n=1}^{\infty }{\frac
{x^{n}}{(n-1)!}}=1+\sum _{n=1}^{\infty }\left({\frac
{1}{n!}}+{\frac {1}{(n-1)!}}\right)x^{n}\\&=1+\sum
_{n=1}^{\infty }{\frac {n+1}{n!}}x^{n}\\&=\sum _{n=0}^{\infty
}{\frac {n+1}{n!}}x^{n}.\end{aligned}}}
Taylor series as definitions[edit]
Classically, algebraic functions are defined by an algebraic
equation, and transcendental functions (including those discussed
above) are defined by some property that holds for them, such as a
differential equation. For example, the exponential function is the
function which is equal to its own derivative everywhere, and
assumes the value 1 at the origin. However, one may equally well
define an analytic function by its Taylor series.
Taylor series are used to define functions and "operators" in diverse areas of mathematics. In particular, this is true in areas where the classical definitions of functions break down. For example, using Taylor series, one may define analytical functions of matrices and operators, such as the matrix exponential or matrix logarithm.
In other areas, such as formal analysis, it is more convenient to work directly with the power series themselves. Thus one may define a solution of a differential equation as a power series which, one hopes to prove, is the Taylor series of the desired solution.
Taylor series in several variables[edit]
The Taylor series may also be generalized to functions of more than
one variable with[11][12]
{\displaystyle {\begin{aligned}T(x_{1},\ldots ,x_{d})&=\sum
_{n_{1}=0}^{\infty }\cdots \sum _{n_{d}=0}^{\infty }{\frac
{(x_{1}-a_{1})^{n_{1}}\cdots (x_{d}-a_{d})^{n_{d}}}{n_{1}!\cdots
n_{d}!}}\,\left({\frac {\partial ^{n_{1}+\cdots +n_{d}}f}{\partial
x_{1}^{n_{1}}\cdots \partial x_{d}^{n_{d}}}}\right)(a_{1},\ldots
,a_{d})\\&=f(a_{1},\ldots ,a_{d})+\sum _{j=1}^{d}{\frac
{\partial f(a_{1},\ldots ,a_{d})}{\partial
x_{j}}}(x_{j}-a_{j})+{\frac {1}{2!}}\sum _{j=1}^{d}\sum
_{k=1}^{d}{\frac {\partial ^{2}f(a_{1},\ldots ,a_{d})}{\partial
x_{j}\partial x_{k}}}(x_{j}-a_{j})(x_{k}-a_{k})+\\&\qquad
\qquad +{\frac {1}{3!}}\sum _{j=1}^{d}\sum _{k=1}^{d}\sum
_{l=1}^{d}{\frac {\partial ^{3}f(a_{1},\ldots ,a_{d})}{\partial
x_{j}\partial x_{k}\partial
x_{l}}}(x_{j}-a_{j})(x_{k}-a_{k})(x_{l}-a_{l})+\cdots
\end{aligned}}} {\displaystyle {\begin{aligned}T(x_{1},\ldots
,x_{d})&=\sum _{n_{1}=0}^{\infty }\cdots \sum
_{n_{d}=0}^{\infty }{\frac {(x_{1}-a_{1})^{n_{1}}\cdots
(x_{d}-a_{d})^{n_{d}}}{n_{1}!\cdots n_{d}!}}\,\left({\frac
{\partial ^{n_{1}+\cdots +n_{d}}f}{\partial x_{1}^{n_{1}}\cdots
\partial x_{d}^{n_{d}}}}\right)(a_{1},\ldots
,a_{d})\\&=f(a_{1},\ldots ,a_{d})+\sum _{j=1}^{d}{\frac
{\partial f(a_{1},\ldots ,a_{d})}{\partial
x_{j}}}(x_{j}-a_{j})+{\frac {1}{2!}}\sum _{j=1}^{d}\sum
_{k=1}^{d}{\frac {\partial ^{2}f(a_{1},\ldots ,a_{d})}{\partial
x_{j}\partial x_{k}}}(x_{j}-a_{j})(x_{k}-a_{k})+\\&\qquad
\qquad +{\frac {1}{3!}}\sum _{j=1}^{d}\sum _{k=1}^{d}\sum
_{l=1}^{d}{\frac {\partial ^{3}f(a_{1},\ldots ,a_{d})}{\partial
x_{j}\partial x_{k}\partial
x_{l}}}(x_{j}-a_{j})(x_{k}-a_{k})(x_{l}-a_{l})+\cdots
\end{aligned}}}
For example, for a function that depends on two variables, x and y,
the Taylor series to second order about the point (a, b) is
{\displaystyle f(a,b)+(x-a)f_{x}(a,b)+(y-b)f_{y}(a,b)+{\frac
{1}{2!}}{\Big
(}(x-a)^{2}f_{xx}(a,b)+2(x-a)(y-b)f_{xy}(a,b)+(y-b)^{2}f_{yy}(a,b){\Big
)}} {\displaystyle f(a,b)+(x-a)f_{x}(a,b)+(y-b)f_{y}(a,b)+{\frac
{1}{2!}}{\Big
(}(x-a)^{2}f_{xx}(a,b)+2(x-a)(y-b)f_{xy}(a,b)+(y-b)^{2}f_{yy}(a,b){\Big
)}}
where the subscripts denote the respective partial derivatives.
A second-order Taylor series expansion of a scalar-valued function of more than one variable can be written compactly as
{\displaystyle T(\mathbf {x} )=f(\mathbf {a} )+(\mathbf {x}
-\mathbf {a} )^{\mathsf {T}}Df(\mathbf {a} )+{\frac
{1}{2!}}(\mathbf {x} -\mathbf {a} )^{\mathsf
{T}}\left\{D^{2}f(\mathbf {a} )\right\}(\mathbf {x} -\mathbf {a}
)+\cdots ,} {\displaystyle T(\mathbf {x} )=f(\mathbf {a} )+(\mathbf
{x} -\mathbf {a} )^{\mathsf {T}}Df(\mathbf {a} )+{\frac
{1}{2!}}(\mathbf {x} -\mathbf {a} )^{\mathsf
{T}}\left\{D^{2}f(\mathbf {a} )\right\}(\mathbf {x} -\mathbf {a}
)+\cdots ,}
where D f (a) is the gradient of f evaluated at x = a and D2 f (a)
is the Hessian matrix. Applying the multi-index notation the Taylor
series for several variables becomes
{\displaystyle T(\mathbf {x} )=\sum _{|\alpha |\geqslant
0}{\frac {(\mathbf {x} -\mathbf {a} )^{\alpha }}{\alpha
!}}\left({\mathrm {\partial } ^{\alpha }}f\right)(\mathbf {a} ),}
{\displaystyle T(\mathbf {x} )=\sum _{|\alpha |\geqslant 0}{\frac
{(\mathbf {x} -\mathbf {a} )^{\alpha }}{\alpha !}}\left({\mathrm
{\partial } ^{\alpha }}f\right)(\mathbf {a} ),}
which is to be understood as a still more abbreviated multi-index
version of the first equation of this paragraph, again in full
analogy to the single variable case.
Example:
Second-order Taylor series approximation (in orange) of a
function f (x,y) = ex log(1 + y) around the origin.
In order to compute a second-order Taylor series expansion around
point (a, b) = (0, 0) of the function
{\displaystyle f(x,y)=e^{x}\log(1+y),} {\displaystyle
f(x,y)=e^{x}\log(1+y),}
one first computes all the necessary partial derivatives:
{\displaystyle
{\begin{aligned}f_{x}&=e^{x}\log(1+y)\\[6pt]f_{y}&={\frac
{e^{x}}{1+y}}\\[6pt]f_{xx}&=e^{x}\log(1+y)\\[6pt]f_{yy}&=-{\frac
{e^{x}}{(1+y)^{2}}}\\[6pt]f_{xy}&=f_{yx}={\frac
{e^{x}}{1+y}}.\end{aligned}}} {\displaystyle
{\begin{aligned}f_{x}&=e^{x}\log(1+y)\\[6pt]f_{y}&={\frac
{e^{x}}{1+y}}\\[6pt]f_{xx}&=e^{x}\log(1+y)\\[6pt]f_{yy}&=-{\frac
{e^{x}}{(1+y)^{2}}}\\[6pt]f_{xy}&=f_{yx}={\frac
{e^{x}}{1+y}}.\end{aligned}}}
Evaluating these derivatives at the origin gives the Taylor
coefficients
{\displaystyle
{\begin{aligned}f_{x}(0,0)&=0\\f_{y}(0,0)&=1\\f_{xx}(0,0)&=0\\f_{yy}(0,0)&=-1\\f_{xy}(0,0)&=f_{yx}(0,0)=1.\end{aligned}}}
{\displaystyle
{\begin{aligned}f_{x}(0,0)&=0\\f_{y}(0,0)&=1\\f_{xx}(0,0)&=0\\f_{yy}(0,0)&=-1\\f_{xy}(0,0)&=f_{yx}(0,0)=1.\end{aligned}}}
Substituting these values in to the general formula
{\displaystyle
T(x,y)=f(a,b)+(x-a)f_{x}(a,b)+(y-b)f_{y}(a,b)+{\frac {1}{2!}}{\Big
(}(x-a)^{2}f_{xx}(a,b)+2(x-a)(y-b)f_{xy}(a,b)+(y-b)^{2}f_{yy}(a,b){\Big
)}+\cdots } {\displaystyle
T(x,y)=f(a,b)+(x-a)f_{x}(a,b)+(y-b)f_{y}(a,b)+{\frac {1}{2!}}{\Big
(}(x-a)^{2}f_{xx}(a,b)+2(x-a)(y-b)f_{xy}(a,b)+(y-b)^{2}f_{yy}(a,b){\Big
)}+\cdots }
produces
{\displaystyle
{\begin{aligned}T(x,y)&=0+0(x-0)+1(y-0)+{\frac {1}{2}}{\Big
(}0(x-0)^{2}+2(x-0)(y-0)+(-1)(y-0)^{2}{\Big )}+\cdots
\\&=y+xy-{\frac {y^{2}}{2}}+\cdots \end{aligned}}}
{\displaystyle {\begin{aligned}T(x,y)&=0+0(x-0)+1(y-0)+{\frac
{1}{2}}{\Big (}0(x-0)^{2}+2(x-0)(y-0)+(-1)(y-0)^{2}{\Big )}+\cdots
\\&=y+xy-{\frac {y^{2}}{2}}+\cdots \end{aligned}}}
Since log(1 + y) is analytic in |y| < 1, we have
{\displaystyle e^{x}\log(1+y)=y+xy-{\frac {y^{2}}{2}}+\cdots ,\qquad |y|<1.} {\displaystyle e^{x}\log(1+y)=y+xy-{\frac {y^{2}}{2}}+\cdots ,\qquad |y|<1.}
Taylor series by Matlab Need Help with part b (a) Find the Taylor expansion of the...
5. Let f(x)- arctan(x) (a) (3 marks) Find the Taylor series about a 0 for f(x). Hint: - arctan(x) - dx You may assume that the Taylor series for f(x) converges to f (x) for values of x in the interval of convergence (b) (3 marks) What is the radius of convergence of the Taylor series for f(x)? Show that the Taylor series converges at x-1. (c) (3 marks) Hence, write T as a series (d) (3 marks) Go to...
5. Let f(z) = arctan(z) (a) (3 marks) Find the Taylor series about r)Hint: darctan( You may assume that the Taylor series for f(x) converges to f(x) for values of r in the interval of convergence (b) (3 marks) What is the radius of convergence of the Taylor series for f(z)? Show that the Taylor series converges at z = 1 (c) (3 marks) Hence, write as a series. (d) (3 marks) Go to https://teaching.smp.uq.edu.au/scims Calculus/Series.html. Use the interactive animation...
Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real-valued functions, the general formula for a Taylor series is given as ia) (a) (z- a) (z- a)2 + £(a (r- a) + + -a + f(x)(a) (1) A special case of the Taylor series (known as the Maclaurin series) exists when a- 0. The Maclaurin series expansions for four commonly used functions in science and engineering are: sin(x) (-1)"...
8. The Maclaurin series (a special case of the Taylor series that is discussed later in this class) allows us to express a differentiable, analytic function as an infinite degree polynomial. Here is the degree seven polynomial approximation of the sine: x3 x5 x? 3! 5! 7! + Use Matlab to generate a plot of sin(x) (solid blue line) and its polynomial approximation (dashed red line) for x = 0 to 31/2 and y from -1.5 to 2. Use the...
Please use matlab to solve the question. 1. The following infinite series can be used to approximate e*: 2 3! n! Prove that this Maclaurin series expansion is a special case of the Taylor series (Eq. 4.13) with Xi = 0 and h a) x. b) Use the Taylor series to estimate f(x) e* at xH1 1 for x-0.25. Employ the zero-, first-, second- and third-order versions and compute the letlfor each case. Take the true value of e10.367879 for...
Section A Q1 0 Using the following Taylor series expansion: f(x+h) = f(x)+hf'(x)+22 h 3! f"(x)+ (+0) (1.1) 4! show that the central finite difference formula for the first derivative can be written as: f'(x)= f(x+h)-f(x-1) + ch" +0(hº) (1.2) 2h Determine cp and of the derived equation. [4 marks] Consider the function: f(x) = sin +COS (1.3) 2 2 Let x =ih with n=0.25, give your answer in 3 decimals for (ii) to (vi): (ii) Evaluate f(x) for i...
1. Taylor series are special power series that are defined from a function f(z) atz = a by fitting higher and higher degree polynomials T, a(x) to the curve at the point (a, f(a)), with the goal of getting a better and better fit as we not only let the degree grow larger, but take a series whose partial sums are these so-called Taylor polynomials Tm,a(x) We will explore how this is done by determine the Taylor series of f(z)...
Solve the Taylor Series. 1. (a) Use the root test to find the interval of convergence of-1)* に0 (b) Demonstrate that the above is the taylor series of f()- by writing a formula for f via taylor's theorem at α-0. That is write f(x)-P(z) + R(x) where P(r) is the nth order taylor polynomial centered at a point a and the remainder term R(x) = ((r - a)n+1 for some c between z and a where here a 0. Show...
Exercise 1: The Taylor series for In(y) about y = 1 is (4) In(y) = 9 (-1)"+(v - 1) n=1 for y-1€ (-1,1] (that is, y E (0,2]). What polynomials do we get if we truncate this series at n = 1? n = 2? n = 0 (hint: the n = Oth approximation is defined!)? Compare the value of each of these with that of In(y) at y = 1.1 and y = 1.75. Note how the error differs...
Only #4!!!! 3 Another Taylor Polynomial Let's compute another Taylor Series, and then call it a day. So let's look at the function f(x) = ln(1 + x), centered at a = 0. 3.1: Compute the first five derivatives of f(x). 3.2: Plug a = 0) into them (as well as the original function) to get f(n)(a) for n from 0 to 5. 3.3: Write down f(n)(a)(x-a)" n! 0,..., 5. Can you infer the general pattern? 3.4: Write down the...