Question

Taylor series by Matlab

Need Help with part b


at 1 so that the associated Taylor (a) Find the Taylor expansion of the function V polynomial has order n. (b). Let us denote the Taylor polynomial obtained in (a) as T.(x). Using Matlab, compute the difference between two values T, (1.1) and v11 for n = 01 2.3, respectively. Collect the above values in a table. What is your observation of the difference in two values when n increases from 0 to 3?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.}

Add a comment
Know the answer?
Add Answer to:
Taylor series by Matlab Need Help with part b (a) Find the Taylor expansion of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT