Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
394 views

#Power Series

Recall from last lecture that a power series centered at x=0x=0 is a series of the form n=0cnxn=c0+c1x+c2x2+c3x3\sum_{n=0}^{\infty} c_n x^n=c_0+c_1 x+c_2 x^2+c_{3} x^{3}\cdots

where all the terms cic_i are constants.

Notice that a power series is a function of xx and the domain of this function is all values of xx for which the series converges. Typically the ratio or root test is used to determine where the series converges.

Recall further that one of the nice things about power series is that it is easy to differentiate and integrate them. As with polynomials, we can take the derivative or integral of each term first, and then add up the results.

ddx(n=0cnxn)=n=0ddx(cnxn)=n=0ncnxn1\frac{d}{dx}\left(\sum_{n=0}^{\infty}c_n x^n\right)=\sum_{n=0}^{\infty}\frac{d}{dx} \left(c_n x^n\right)=\sum_{n=0}^{\infty} n c_n x^{n-1}(n=0cnxn)dx=n=0(cnxndx)=n=0cnn+1xn+1+C\int\left(\sum_{n=0}^{\infty}c_n x^n\right)dx=\sum_{n=0}^{\infty}\left(\int c_n x^n dx\right)=\sum_{n=0}^{\infty} \frac{c_n}{n+1} x^{n+1}+C

Last time we were primarily concerned with estimating or finding the function that the power series represents. For example we use the geometric sum fomula to find that for x<1\left| x\right|<1,

n=0cxn=c+cx+cx2+cx3+=c1x\sum_{n=0}^{\infty}c x^n=c+cx+cx^{2}+cx^{3}+\cdots=\frac{c}{1-x}

The partial sums of this power series, gave a polynomial approximation of the functin c1x\displaystyle \frac{c}{1-x}. Using c=1c=1 and partial sums with N=3,10N=3,10 and 3030 terms we notice that the functions begin to converge to the actual function. (In Black)

n=var('n') plot1=plot(1/(1-x),x,-1,1,color='black',ymax=10) plot3=plot(sum(x^n,n,0,3),x,-1,1,color='red',ymax=10) plot10=plot(sum(x^n,n,0,10),x,-1,1,color='blue',ymax=10) plot30=plot(sum(x^n,n,0,30),x,-1,1,color='green',ymax=10) show(plot1+plot3+plot10+plot30)

###Taylor Series

What about the other direction? Given a function, can we find a power series that represents the function on some interval? For example, can we find a power series that converges to sin(x)\sin(x), or ln(x)\ln(x) or exe^{x}? The answer is yes!

To find this representation, we need to know what to choose for the coefficients cnc_{n}.

Suppose that ff has a power series representation (this is a critical assumption) of a function ff so that,

f(x)=n=0cnxn.f(x)=\sum_{n=0}^{\infty}c_{n}x^{n}.

To find the coefficients cnc_{n} we use evaluation at x=0x=0 and differentiation.

Plugging in x=0x=0 into both sides of the equation gives,

f(0)=c0+c10+c202+c303+=c0.f(0)=c_{0}+c_{1}0+c_{2}0^2+c_{3}0^3+\cdots=c_{0}.

Thus the first coefficient c0=f(0)c_{0}=f(0) the function value at x=0x=0.

Now to find c1c_{1}, we differentiate, then plug in x=0x=0.

Differentiating we find,

f(x)=c1+2c2x+3c3x2+4c4x3+f'(x)=c_{1}+2c_{2}x+3c_{3}x^{2}+4c_{4}x^{3}+\cdots

At x=0x=0 this equality gives,

f(0)=c1+2c20+3c302+=c1f'(0)=c_{1}+2c_{2}0+3c_{3}0^{2}+\cdots=c_{1}

Therefore, c1=f(0)c_{1}=f'(0).

Continuing this process by differentiating and evaluation at x=0x=0, we get the general formula,

cn=f(n)(0)n!c_{n}=\frac{f^{(n)}(0)}{n!}

With f(x)=n=0f(n)(0)n!xn\displaystyle f(x)=\sum_{n=0}^{\infty}\frac{f^{(n)}(0)}{n!}x^{n}.

This process of representing a function by a power series is called "expanding" the function into a series. The power series you get is called a Taylor series expansion of f(x)f(x), after mathematician Brook Taylor (1685-1731).

Expanding functions into Taylor series and differentiating and integrating the series had a number of applications back then. For example, you can use Taylor Series to approximate the values of numbers like π\pi and ee. Or consider the logarithmic and trigonometric functions. These are often difficult to calculate, but if you expand these into Taylor series, then you can approximate values of these functions using only polynomials (and polynomials only require arithmetic to calculate).

Fortunately, finding the right power series to represent a function is fairly straightforward, as long as the function is repeatedly differentiable. The secret is to find derivatives of every order and evaluate them at x=ax=a.


Conclusion: If a function f(x)f(x) with derivatives of every order may be represented by a power series centered at x=0x=0 on some interval II, then that power series is f(x)=n=0f(n)(0)n!xnf(x)=\sum_{n=0}^{\infty}\frac{f^{(n)}(0)}{n!}x^n

where the series converges on the interval II.

Notice the "if" in the last sentence. There are functions that are not equal to the sum of their Taylor series, even if the series converges.

For Taylor Series not centered at x=0x=0, the Taylor Series of a function centered x=ax=a is,

f(x)=n=0f(n)(a)n!(xa)nf(x)=\sum_{n=0}^{\infty}\frac{f^{(n)}(a)}{n!}(x-a)^n

where the derivatives are evaluated at the new center point.

###Example 1

Find the Taylor series of f(x)=exf(x)=e^x centered at x=0x=0 (Taylor series centered at 0 are also called Maclaurin series).

We know f(n)(x)=f(x)=exf^{(n)}(x)=f(x)=e^x in this case. Since e0=1e^0=1, we have f(n)(0)=1f^{(n)}(0)=1 for all nn.

Thus, cn=1n!\displaystyle c_n=\frac{1}{n!}.

If exe^x equals the sum of its Taylor series, then ex=n=0xnn!=1+x+12x2+16x3+124x4\displaystyle e^x=\sum_{n=0}^{\infty}\frac{x^n}{n!}=1+x+\frac{1}{2}x^{2}+\frac{1}{6}x^{3}+\frac{1}{24}x^{4}\cdots. For this particular function, the Taylor series converges for all xx, and exe^x does equal the sum of the series (take my word for it).

###Taylor Polynomials

The partial sums of a Taylor series are actual polynomials, called Taylor polynomials. In other words, the Taylor polynomial of degree mm is n=0mf(n)(a)n!(xa)n\displaystyle\sum_{n=0}^m\frac{f^{(n)}(a)}{n!}(x-a)^n.

We can approximate a Taylor series to whatever level of accuracy we want by using a Taylor polynomial of high enough degree.


Notice that the Taylor polynomial of degree 1 is n=01f(n)(a)n!(xa)n=f(0)(a)0!(xa)0+f(1)(a)1!(xa)1=f(a)+f(a)(xa)\displaystyle\sum_{n=0}^1\frac{f^{(n)}(a)}{n!}(x-a)^n=\frac{f^{(0)}(a)}{0!}(x-a)^0+\frac{f^{(1)}(a)}{1!}\cdot(x-a)^1=f(a)+f'(a)(x-a).

Does this look familiar? It should! This is an equation for the tangent line to ff at aa. In other words, Taylor polynomials are generalizations of the tangent line to higher degree polynomials.

###Example 2

We will use Taylor polynomials to approximate the value of e4e^4. We saw above that ex=n=0xnn!\displaystyle e^x=\sum_{n=0}^{\infty}\frac{x^n}{n!}.

The Taylor polynomial of degree mm is n=0mxnn!=1+x+x22+x36++xmm!\displaystyle\sum_{n=0}^{m}\frac{x^n}{n!}=1+x+\frac{x^2}{2}+\frac{x^3}{6}+\cdots+\frac{x^m}{m!}.

So ex1+x+x22+x36++xmm!\displaystyle e^x\approx 1+x+\frac{x^2}{2}+\frac{x^3}{6}+\cdots+\frac{x^m}{m!}. The approximation improves as mm increases.

n=var('n') plot1=plot(e^x,x,-1,7,color='black',ymax=200) plot3=plot(sum(x^n/factorial(n),n,0,3),x,-1,7,color='red',ymax=200) plot5=plot(sum(x^n/factorial(n),n,0,5),x,-1,7,color='blue',ymax=200) plot10=plot(sum(x^n/factorial(n),n,0,10),x,-1,7,color='green',ymax=200) show(plot1+plot3+plot5+plot10)
If we plug in x=4x=4, we get e41+4+422+436++4mm!\displaystyle e^4\approx 1+4+\frac{4^2}{2}+\frac{4^3}{6}+\cdots+\frac{4^m}{m!}. Let's approximate the value of e4e^4.
n=var('n') @interact def _(m=input_box(1,label='Degree of Taylor polynomial',width=20)): print "Approximation =",sum(4^n/factorial(n),n,0,m).n(digits=30) print "Actual value =",e^4.n(digits=30)
Interact: please open in CoCalc

How big must mm be so that our approximation is correct for all the decimal places shown?

###Example 3

We can use Sage to calculate Taylor polynomials using the "taylor" command. This command takes four arguments: the expression or function to expand, the variable of expansion, the center of the expansion, and the degree of polynomial you want.

Use Sage to find the 10th-degree Taylor polynomial centered at x=0x=0 for f(x)=exf(x)=e^x.

show(taylor(e^x,x,0,10))
13628800x10+1362880x9+140320x8+15040x7+1720x6+1120x5+124x4+16x3+12x2+x+1\frac{1}{3628800} \, x^{10} + \frac{1}{362880} \, x^{9} + \frac{1}{40320} \, x^{8} + \frac{1}{5040} \, x^{7} + \frac{1}{720} \, x^{6} + \frac{1}{120} \, x^{5} + \frac{1}{24} \, x^{4} + \frac{1}{6} \, x^{3} + \frac{1}{2} \, x^{2} + x + 1

###Example 4

Find the 15th-degree Taylor polynomials of sin(x)\sin(x) centered at x=0x=0, x=π/2x=\pi/2, and x=π/4x=\pi/4.

show(taylor(sin(x),x,0,9))
1362880x915040x7+1120x516x3+x\displaystyle \frac{1}{362880} \, x^{9} - \frac{1}{5040} \, x^{7} + \frac{1}{120} \, x^{5} - \frac{1}{6} \, x^{3} + x
plot(sin(x),x,-3*pi,3*pi)+plot(taylor(sin(x),x,0,9),x,-3*pi,3*pi,color='red',ymax=3,ymin=-3)
show(taylor(sin(x),x,pi/2,9))
110321920(π2x)8146080(π2x)6+1384(π2x)418(π2x)2+1\displaystyle \frac{1}{10321920} \, {\left(\pi - 2 \, x\right)}^{8} - \frac{1}{46080} \, {\left(\pi - 2 \, x\right)}^{6} + \frac{1}{384} \, {\left(\pi - 2 \, x\right)}^{4} - \frac{1}{8} \, {\left(\pi - 2 \, x\right)}^{2} + 1
plot(sin(x),x,-3*pi,3*pi)+plot(taylor(sin(x),x,pi/2,9),x,-3*pi,3*pi,color='red',ymax=3,ymin=-3)
show(taylor(sin(x),x,pi/4,9))
11902536294402(π4x)9+152848230402(π4x)8+11651507202(π4x)7158982402(π4x)612457602(π4x)5+1122882(π4x)4+17682(π4x)31642(π4x)2182(π4x)+122\displaystyle -\frac{1}{190253629440} \, \sqrt{2} {\left(\pi - 4 \, x\right)}^{9} + \frac{1}{5284823040} \, \sqrt{2} {\left(\pi - 4 \, x\right)}^{8} + \frac{1}{165150720} \, \sqrt{2} {\left(\pi - 4 \, x\right)}^{7} - \frac{1}{5898240} \, \sqrt{2} {\left(\pi - 4 \, x\right)}^{6} - \frac{1}{245760} \, \sqrt{2} {\left(\pi - 4 \, x\right)}^{5} + \frac{1}{12288} \, \sqrt{2} {\left(\pi - 4 \, x\right)}^{4} + \frac{1}{768} \, \sqrt{2} {\left(\pi - 4 \, x\right)}^{3} - \frac{1}{64} \, \sqrt{2} {\left(\pi - 4 \, x\right)}^{2} - \frac{1}{8} \, \sqrt{2} {\left(\pi - 4 \, x\right)} + \frac{1}{2} \, \sqrt{2}
plot(sin(x),x,-3*pi,3*pi)+plot(taylor(sin(x),x,pi/4,9),x,-3*pi,3*pi,color='red',ymax=3,ymin=-3)

Notice that the coefficients can depend heavily on the center point. For example using the center point x=0x=0 all the even terms are zero, but for center x=π/2x=\pi/2 the odd terms are zero. Centering our expansion at x=π/4x=\pi/4 gives both even and odd terms. Moreover, the accuracy will be greater towards the center point. If using at Taylor Series to approximate a value, picking a convienient center point close to your approximating point will allow you to use less terms in your series.

###Example 5

Find the Taylor polynomials of cos(x)\cos(x) centered at x=0x=0 of degrees 5, 10, and 15. And generate a plot with all three.

show(taylor(cos(x),x,0,5))
124x412x2+1\frac{1}{24} \, x^{4} - \frac{1}{2} \, x^{2} + 1
show(taylor(cos(x),x,0,10))
13628800x10+140320x81720x6+124x412x2+1-\frac{1}{3628800} \, x^{10} + \frac{1}{40320} \, x^{8} - \frac{1}{720} \, x^{6} + \frac{1}{24} \, x^{4} - \frac{1}{2} \, x^{2} + 1
show(taylor(cos(x),x,0,15))
187178291200x14+1479001600x1213628800x10+140320x81720x6+124x412x2+1-\frac{1}{87178291200} \, x^{14} + \frac{1}{479001600} \, x^{12} - \frac{1}{3628800} \, x^{10} + \frac{1}{40320} \, x^{8} - \frac{1}{720} \, x^{6} + \frac{1}{24} \, x^{4} - \frac{1}{2} \, x^{2} + 1
plot1=plot(taylor(cos(x),x,0,5),x,-2*pi,2*pi,ymax=3,ymin=-3,color='red') plot2=plot(taylor(cos(x),x,0,10),x,-2*pi,2*pi,ymax=3,ymin=-3,color='blue') plot3=plot(taylor(cos(x),x,0,15),x,-2*pi,2*pi,ymax=3,ymin=-3,color='green') show(plot1+plot2+plot3)

###Example 6

Estimate 0πsin(x2)dx\displaystyle \int_{0}^{\sqrt{\pi}}\sin(x^{2})dx using the 10-degree Taylor polynomial centered at x=0x=0.

Here we find 10th Degree Taylor polynomial of sin(x2)\sin(x^{2}) and use this to evaluate the integral.

T10(x)=taylor(sin(x^2),x,0,10) show(T10(x))
1120x1016x6+x2\displaystyle \frac{1}{120} \, x^{10} - \frac{1}{6} \, x^{6} + x^{2}
plot(sin(x^2),x,0,sqrt(pi))+plot(T10(x),x,0,sqrt(pi),color='red')
integrate(T10(x),x,0,1).n()
0.310281385281385
This is very close to what Sage finds using its internal numerical integration routine.
numerical_integral(sin(x^2),0,sqrt(pi))
(0.894831469484145, 9.93462500580461e-15)

#Taylor Series Assignment

###Question 1

Let f(x)=esin(x)\displaystyle f(x)=e^{\sin(x)}, T5(x)=T5(x)= the 5th-degree Taylor polynomial of ff centered at x=πx=\pi, and T10(x)=T10(x)= the 10th-degree Taylor polynomial of ff centered at x=πx=\pi.

Graph all three on the window 0x2π0\le x \le 2\pi, 0y30\le y \le 3. Use black for ff, blue for T5T5, and red for T10T10.

###Question 2

Use Taylor polynomials to approximate π\pi using the following steps:

  • A=0141+x2dx=4arctan(1)4arctan(0)=πA=\displaystyle\int_0^1 \frac{4}{1+x^2}\, dx=4\arctan(1)-4\arctan(0)=\pi

  • T(x)=T(x)= Taylor polynomial of degree 100 of 41+x2\displaystyle\frac{4}{1+x^2} centered at x=0x=0

  • B=01T(x)dxB=\displaystyle\int_0^1 T(x)\, dx

  • Use the fact that AA and BB are approximately equal to approximate π\pi. [Use the n() command to convert to a decimal.]

###Question 3 Consider the function f(x)=sin(3x)ex2/4f(x)=\sin(3x)e^{-x^{2}/4}.

  • Find a Taylor Polynomial with high enough degree that the plot of ff and the Taylor polynomial on the interval [0,3]\left[0,3\right] are indistinguishable.

  • Estimate the value of 03sin(3x)ex2/4dx\displaystyle \int_{0}^{3}\sin(3x)e^{-x^{2}/4}dx by integrating your Taylor polynomial.

  • Compare your results with the output from Sage's numerical_integral command: 0.3758174640.375817464. [Use the n() command to convert to decimals.]