Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 157
Image: ubuntu2204
Kernel: SageMath 10.1

Power Series, Taylor Series

Power Series: infinite polynomials

A power series about x=0x=0 is a series of the form n=0cnxn=c0+c1x+c2x2++cnxn+.\sum_{n=0}^\infty c_nx^n=c_0+c_1x+c_2x^2+\cdots+c_nx^n+\cdots. A power series about x=ax=a is a series of the form n=0cn(xa)n=c0+c1(xa)+c2(xa)2++cn(xa)n+,\sum_{n=0}^\infty c_n(x-a)^n=c_0+c_1(x-a)+c_2(x-a)^2+\cdots+c_n(x-a)^n+\cdots, where the center aa and the coefficients c0,c1,c2,,cn,c_0,c_1,c_2,\cdots,c_n,\cdots are constants.

Example

Let cn=1c_n=1 for all nn, we have n=0xn\sum_{n=0}^\infty x^n

We consider xx as a constant, it is the geometric series. The series converges when x(1,1)x\in (-1,1), and it converges to 11x{1\over 1-x}.

var('x, n') xmin = -1 xmax = 1 ymin = 0 ymax = 7 f = 1/(1-x) a(n) = x^n g = plot(f, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, color = 'cyan', legend_label = r'$%s$'%latex(f)) # for loop to plot lines with different color for nmax, color in zip([0, 1, 2, 7], ['blue', 'red', 'black', 'green']): f = sum(a(n), n, 0, nmax) g += plot(f, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, color = color, legend_label = '$%s$'%latex(f)) g.show()
Image in a Jupyter notebook

Convergence of a Power Series

n=1(1)n1xnn\sum_{n=1}^\infty (-1)^{n-1}{x^n\over n}
  • It diverges when x>1|x|>1 because limnxnn0\lim\limits_{n\rightarrow\infty} {x^n\over n}\neq 0.

  • It converges when x<1|x|<1.

  • It diverges when x=1x=-1

  • It converges when x=1x=1

var('n, x') f(n) = (-1)^(n-1)*x^n/n print('The power series of', f(n), 'converges to', sum(f(n), n, 1, Infinity))
The power series of (-1)^(n - 1)*x^n/n converges to log(x + 1)
var('x, n') xmin = -1 xmax = 1.1 ymin = -3 ymax = 1 f = log(1+x) a(n) = (-1)^(n-1)*x^n/n g = plot(f, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, color = 'cyan', legend_label = r'$%s$'%latex(f)) # for loop to plot lines with different color for nmax, color in zip([1, 2, 3, 8], ['blue', 'red', 'black', 'green']): f = sum(a(n), n, 1, nmax) g += plot(f, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, color = color, legend_label = r'$%s$'%latex(f)) g.show()
Image in a Jupyter notebook
n=1(1)n1x2n1(2n1)\sum_{n=1}^\infty (-1)^{n-1}{x^{2n-1}\over (2n-1)}
  • It diverges when x>1|x|>1 because limx2n12n10\lim {x^{2n-1}\over 2n-1}\neq 0.

  • It converges when x<1|x|<1.

  • It converges when x=1x=-1

  • It converges when x=1x=1

var('n, x') a(n) = (-1)^(n-1)*x^(2*n-1)/(2*n-1) print('The power series of', a(n), 'converges to', sum(a(n), n, 1, Infinity))
The power series of (-1)^(n - 1)*x^(2*n - 1)/(2*n - 1) converges to arctan(x)
var('x') xmin = -1.3 xmax = 1.3 ymin = -2 ymax = 2 f = arctan(x) a(n) = (-1)^(n-1)*x^(2*n-1)/(2*n-1) g = plot(f, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, color = 'cyan', legend_label = r'$%s$'%latex(f)) # for loop to plot lines with different color for nmax, color in zip([1, 2, 3, 8], ['blue', 'red', 'black', 'green']): f = sum(a(n), n, 1, nmax) g += plot(f, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, color = color, legend_label = r'$%s$'%latex(f)) g.show()
Image in a Jupyter notebook
n=1xnn!\sum_{n=1}^\infty {x^n\over n!}
  • It converges for all xx

var('n, x') a(n) = x^n/factorial(n) print('The power series of', a(n), 'converges to', sum(a(n), n, 1, Infinity)) xmin = -5 xmax = 2 ymin = -2 ymax = 2 f = e^x - 1 g = plot(f, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, color = 'cyan', legend_label = r'$%s$'%latex(f)) # for loop to plot lines with different color for nmax, color in zip([1, 2, 3, 8], ['blue', 'red', 'black', 'green']): f = sum(a(n), n, 1, nmax) g += plot(f, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, color = color, legend_label = r'$%s$'%latex(f)) g.show()
The power series of x^n/factorial(n) converges to 2*e^(1/2*x)*sinh(1/2*x)
Image in a Jupyter notebook

Convergence Theorem for Power Series

If the power series n=0anxn\sum_{n=0}^\infty a_n x^n converges at x=cx=c with c>0|c|> 0, then it converges absolutely for all x(c,c)x\in (-|c|,|c|), If the series diverges at x=dx=d, then it diverges for all xx with x>d|x|>|d|.

If it converges at x=cx=c, then we have that ancn0|a_nc^n|\rightarrow 0. That is, there exist NN such that an<cna_n<|c|^{-n} for all n>Nn>N.

  • Root test, for any x(c,c)x\in (-|c|,|c|), we have anxnn=annx<1\sqrt[n]{|a_nx^n|}=\sqrt[n]{|a_n|}|x|<1 for n>Nn>N, therefore, it convergs for x(c,c)x\in(-|c|,|c|).

If it diverges at x=dx=d,then we can prove by contradiction, that it diverges for x>d|x|>d.

The convergence of the series cn(xa)n\sum c_n(x - a)^n is described by one of the following three cases:

  • There is a positive number RR such that the series diverges for xx with xa>R|x - a|> R but converges absolutely for xx with xa<R|x - a|< R. The series may or may not converge at either of the endpoints x=aRx = a - R and x=a+Rx = a + R.

  • The series converges absolutely for every xx (R=R = \infty).

  • The series converges at x=ax = a and diverges elsewhere (R=0R = 0).

RR is called the radius of convergence of the power series, and the interval of radius RR centered at x=ax=a is called the the interval of convergence. The interval may be open, closed, or half-open.

Steps to test the convergence of a power series

  • Use Ratio Test or Root Test to find the radius RR.

  • If RR is finite and positive. Test both endpoints using Comparison Test, Interal Test, or Alternating Series Test

Operations on Power Series

If A(x)=n=0anxnA(x)=\sum_{n=0}^{\infty}a_nx^n and B(x)=n=0bnxnB(x)=\sum_{n=0}^\infty b_nx^n converge absolutely for x<R|x|<R, and cn=a0bn+a1bn1+a2bn2++an1b1+anb0=k=0nakbnkc_n=a_0b_n+a_1b_{n-1}+a_2b_{n-2}+\cdots+a_{n-1}b_1+a_nb_0=\sum_{k=0}^na_kb_{n-k} then n=0cnxn\sum_{n=0}^\infty c_nx^n converges absolutely to A(x)B(x)A(x)B(x) for x<R|x|<R: n=0anxnn=0bnxn=n=0cnxn\sum_{n=0}^\infty a_nx^n \sum_{n=0}^\infty b_nx^n=\sum_{n=0}^\infty c_n x^n

Substitute a function in a convergent power series

If n=0anxn\sum_{n=0}^\infty a_nx^n converges absolutely for x<R|x|<R, then n=0an(f(x))n\sum_{n=0}^\infty a_n(f(x))^n converges absolutely for any continuous function ff on f(x)<R|f(x)|<R.

The Term-by-Term Differentiation Theorem

If cn(xa)n\sum c_n(x-a)^n has radius of convergence R>0R>0, it defines a function f(x)=n=0cn(xa)n, on the interval aR<x<a+Rf(x)=\sum_{n=0}^\infty c_n(x-a)^n,\mbox{ on the interval } a-R<x<a+R The function ff has derivatives of all orders inside the interval, and we obtain the derivatives by differentiating the original series terms by term: f(x)=n=1ncn(xa)n1f(x)=n=2n(n1)cn(xa)n2\begin{align*}f'(x)=&\sum_{n=1}^\infty nc_n(x-a)^{n-1}\\ f''(x)=&\sum_{n=2}^\infty n(n-1)c_n(x-a)^{n-2}\end{align*}

The Term-by-Term Integration Theorem

If f(x)=n=0cn(xa)nf(x)=\sum_{n=0}^\infty c_n(x-a)^n converges for xa<R|x-a|<R. Then n=0cn(xa)n+1n+1\sum_{n=0}^\infty c_n{(x-a)^{n+1}\over n+1} converges for xa<R|x-a|<R and f(x)dx=n=0cn(xa)n+1n+1+C\int f(x)dx=\sum_{n=0}^\infty c_n{(x-a)^{n+1}\over n+1}+C for xa<R|x-a|<R.

Example

f(x):=n=0(1)nx2n+12n+1f(x):=\sum_{n=0}^\infty {(-1)^nx^{2n+1}\over 2n+1}

Taking derivative, we have f(x):=n=0(1)nx2n=11+x2.f'(x):=\sum_{n=0}^\infty {(-1)^nx^{2n}} = {1\over 1+x^2}.

So we have f(x)=arctan(x)f(x)=\arctan(x).

Series Representation

Assume that ff is the sum of a power series about x=ax=a: f(x)=n=0an(xa)n=a0+a1(xa)+a2(xa)2++an(xa)n+f(x)= \sum_{n=0}^\infty a_n(x-a)^n=a_0+a_1(x-a)+a_2(x-a)^2+\cdots+a_n(x-a)^n+\cdots

  • f(a)=a0f(a)=a_0

  • f(a)=1!a1f'(a)=1!\cdot a_1

  • f(a)=2!a2f''(a)=2!\cdot a_2

  • f(a)=3!a3f'''(a)=3! \cdot a_3 f(x)=f(a)+f(a)(xa)+f(a)2!(xa)2++f(n)(a)n!(xa)n+f(x)= f(a)+f'(a)(x-a)+{f''(a)\over 2!}(x-a)^2+\cdots+{f^{(n)}(a)\over n!}(x-a)^n+\cdots

Taylor and Maclaurin Series

Let ff be a function with derivatives of all orders throughout some interval containing aa as an interior point. Then its Taylor series at x=ax=a is f(a)+f(a)(xa)+f(a)2!(xa)2++f(n)n!(xa)n+=k=0f(k)(a)k!(xa)k.f(a)+f'(a)(x-a)+{f''(a)\over 2!}(x-a)^2+\cdots+{f^{(n)}\over n!}(x-a)^n+\cdots=\sum_{k=0}^\infty {f^{(k)}(a)\over k!}(x-a)^k. The Maclaurin series of ff is the Taylor series at x=0x=0, or f(0)+f(0)x+f(0)2!x2++f(n)(0)n!xn+=k=0f(k)(0)k!xk.f(0)+f'(0)x+{f''(0)\over 2!}x^2+\cdots+{f^{(n)}(0)\over n!}x^n+\cdots=\sum_{k=0}^\infty {f^{(k)}(0)\over k!}x^k.

Find the Taylor series generated by f(x)=1xf(x)={1\over x} at x=2x=2. When does it converge to 1/x1/x?

We can find that f(n)(x)=(1)nn!xn+1f^{(n)}(x)={(-1)^{n}n!\over x^{n+1}}

It converges when x(0,4)x\in (0,4).

f = 1/x x0 = 2 n = 10 print('The first', n, 'terms of the Taylor series of', f, 'at x=', x0, 'is\n', taylor(1/x,x,2,10))
The first 10 terms of the Taylor series of 1/x at x= 2 is 1/2048*(x - 2)^10 - 1/1024*(x - 2)^9 + 1/512*(x - 2)^8 - 1/256*(x - 2)^7 + 1/128*(x - 2)^6 - 1/64*(x - 2)^5 + 1/32*(x - 2)^4 - 1/16*(x - 2)^3 + 1/8*(x - 2)^2 - 1/4*x + 1
var('x') xmin = 0 xmax = 5 ymin = 0 ymax = 3 f = 1/x g = plot(f, xmin = xmin, xmax = xmax, ymax = ymax, ymin = ymin, color = 'cyan', legend_label = r'$%s$'%latex(f)) # for loop to plot lines with different color for nmax, color in zip([1, 2, 3, 4], ['blue', 'red', 'black', 'green']): tf = taylor(f,x,2,nmax) g += plot(tf, xmin = xmin, xmax = xmax, ymax = ymax, ymin = ymin, color = color, legend_label = r'$%s$'%latex(tf)) g.show()
Image in a Jupyter notebook

Taylor Polynomials

Let ff be a function with derivatives of order up to NN in some interval containing aa as an interior point. Then for any integer nn from 0 through NN, the Taylor polynomial of order nn generated by ff at x=ax=a is Pn(x)=f(a)+f(a)(xa)+f(a)2!(xa)2++f(n)(a)n!(xa)n.P_n(x)=f(a)+f'(a)(x-a)+{f''(a)\over 2!}(x-a)^2+\cdots+{f^{(n)}(a)\over n!}(x-a)^n.

# Example e^x var('x') xmin = -1 xmax = 1.3 ymin = 0 ymax = 3 f = e^x g = plot(e^x, xmin = xmin, xmax = xmax, ymax = ymax, ymin = ymin, color = 'cyan', legend_label = r'$%s$'%latex(f)) # for loop to plot lines with different color for nmax, color in zip([1..3], ['blue', 'red', 'black']): tf = taylor(f,x,0,nmax) g += plot(tf, xmin = xmin, xmax = xmax, ymax = ymax, color = color, legend_label = r'$%s$'%latex(tf)) g.show()
Image in a Jupyter notebook
# Example cos(x) var('x') xmin = 0 xmax = 9 ymin = -2 ymax = 2 f = cos(x) g = plot(cos(x), xmin = xmin, xmax = xmax, ymax = ymax, ymin = ymin, color = 'cyan', legend_label = r'$%s$'%latex(f)) # for loop to plot lines with different color for nmax, color in zip([1+2*n for n in [0..7]], ['blue', 'red', 'black', 'green', 'blue', 'red', 'black', 'green']): tf = taylor(f,x,0,nmax) g += plot(tf, xmin = xmin, xmax = xmax, ymax = ymax, ymin = ymin, color = color, legend_label = '$P_{%s}$'%latex(nmax-1)) g.show()
Image in a Jupyter notebook

Two questions.

When does the Taylor series converge to its generating function?

How accurately does a Taylor polynomial approximatie the function on a given interval?

Taylor's Theorem

If ff and its first nn derivatives ff', f,,f(n)f'', \cdots, f^{(n)} are continuous on an open interval II containing aa, and f(n)f^{(n)} is differentiable on the same interval, then for given xIx\in I, there exist a number cc between aa and xx such that f(x)=f(a)+f(a)(xa)+f(a)2!(xa)2++f(n)(a)n!(xa)n+f(n+1)(c)(n+1)!(xa)n+1.=f(a)+f(a)(xa)+f(a)2!(xa)2++f(n)(a)n!(xa)n+Rn(x).\begin{align*}f(x) =&{\color{blue}f(a)+f'(a)(x-a)+{f''(a)\over 2!}(x-a)^2+\cdots+{f^{(n)}(a)\over n!}(x-a)^n}\\ &+{\color{red}{f^{(n+1)}(c)\over (n+1)!}(x-a)^{n+1}}.\\ =&{\color{blue}f(a)+f'(a)(x-a)+{f''(a)\over 2!}(x-a)^2+\cdots+{f^{(n)}(a)\over n!}(x-a)^n}\\ &+{\color{red}R_n(x)}.\\ \end{align*} The function Rn(x)R_n(x) is the remainder of order nn or the error term for using Pn(x)P_n(x) approximate ff over the interval II.

If Rn(x)0R_n(x)\rightarrow 0 as nn\rightarrow \infty for all xIx\in I, we say that the Taylor series PnP_n generated by ff at x=ax=a converges to ff on II, and we write f(x)=k=0f(k)(a)k!(xa)kf(x)=\sum_{k=0}^\infty {f^{(k)}(a)\over k!}(x-a)^k

The Remainder Estimation Theorem

If there is a positive constant MM such that f(n+1)(t)M|f^{(n+1)}(t)|\leq M for all tt between xx and aa, inclusive, then the remainder term Rn(x)R_n(x) in Taylor's Theorem satisfies the inequality Rn(x)Mxan+1(n+1)!|R_n(x)|\leq M{|x-a|^{n+1}\over (n+1)!} If this inequality (the same MM) holds for every nn and the order conditions of Taylor's theorem are satisfied by ff, then the series converges to f(x)f(x).

Example

For what xx can we replace cosx\cos x by 1(x2/2!)1-(x^2/2!) with an error of magnitude no greater than 3×1043\times 10^{-4}.

# Example cos(x) var('x') xmin = -1 xmax = 1 ymin = 0.4 ymax = 1.1 f = cos(x) g = plot(f, xmin = xmin, xmax = xmax, ymax = ymax, ymin = ymin, color = 'cyan', legend_label = r'$%s$'%latex(f)) # for loop to plot lines with different color for nmax, color in zip([1+2*n for n in [0..2]], ['blue', 'red', 'black']): tf = taylor(f,x,0,nmax) g += plot(tf, xmin = xmin, xmax = xmax, ymax = ymax, ymin = ymin, color = color, legend_label = r'$P_{%s}$'%latex(nmax-1)) g.show()
Image in a Jupyter notebook

The Binomial Series for Powers and Roots

For a given constant mm (can be non-integer), computer the Taylor series generated by f(x)=(1+x)mf(x)=(1+x)^m at x=0x=0. 1+mx+m(m1)2!x2+m(m1)(m2)3!x3++m(m1)(m2)(mk+1)k!xk+\begin{align*} 1+mx+{m(m-1)\over 2!}x^2+&{m(m-1)(m-2)\over 3!}x^3 + \cdots \\ +& {m(m-1)(m-2)\cdots(m-k+1)\over k!}x^k+\cdots \end{align*} This is called binomial series, which converges absolutely for x<1|x|<1.

  • If mm is a positive integer or 0, finite terms

  • If mm is not a positive integer or 0, infinitely many terms

The Binomial Series

For x<1|x|<1, (1+x)m=1+k=1(mk)xk,(1+x)^m = 1+\sum_{k=1}^\infty \begin{pmatrix} m\\k \end{pmatrix}x^k, where we define

(mk)=m(m1)(m2)(mk+1)k!.\begin{pmatrix} m\\k \end{pmatrix} ={m(m-1)(m-2)\cdots(m-k+1)\over k!}.
  • 1+x\sqrt{1+x}

We can compute its Taylor series at x=0x=0.

  • 1x2\sqrt{1-x^2}

We can compute its Taylor series at x=0x=0.

  • 11x\sqrt{1-{1\over x}}

We can not compute its Taylor series at x=0x=0 because it is not defined at x=0x=0.

n = 8 print('The terms with order no greater than', n, 'of', sqrt(1+x), 'is\n', taylor(sqrt(1+x),x,0,n)) print('\nThe terms with order no greater than', n, 'of', sqrt(1-x^2), 'is\n', taylor(sqrt(1-x^2),x,0,n))
The terms with order no greater than 8 of sqrt(x + 1) is -429/32768*x^8 + 33/2048*x^7 - 21/1024*x^6 + 7/256*x^5 - 5/128*x^4 + 1/16*x^3 - 1/8*x^2 + 1/2*x + 1 The terms with order no greater than 8 of sqrt(-x^2 + 1) is -5/128*x^8 - 1/16*x^6 - 1/8*x^4 - 1/2*x^2 + 1

Example

Evaluating Nonelementary Integrals sinx2dx\int \sin x^2 dx and estimate 01sinx2dx\int_0^1\sin x^2 dx

reset() var('x') f = sin(x^2) n_end = 20 show(taylor(f, x, 0, n_end).integral(x)) g = point((n, taylor(f, x, 0, n).integral(x).substitute(x=1)) for n in [1..n_end]) g += line([(0, f.integral(x, 0, 1)), (n_end, f.integral(x, 0, 1))], color='red', legend_label='true value') g.show()

16894720x19175600x15+11320x11142x7+13x3\displaystyle \frac{1}{6894720} \, x^{19} - \frac{1}{75600} \, x^{15} + \frac{1}{1320} \, x^{11} - \frac{1}{42} \, x^{7} + \frac{1}{3} \, x^{3}

Image in a Jupyter notebook

Use Taylor series to find a limit

  • limx1lnxx1\lim\limits_{x\rightarrow 1}{\ln x\over x-1}

It is 00{0\over 0}, we can just use Taylor series. limx1lnxx1=limx1x1x1=1\lim\limits_{x\rightarrow 1}{\ln x\over x-1}=\lim\limits_{x\rightarrow 1}{x-1\over x-1}=1

  • limx0(1sinx1x)\lim\limits_{x\rightarrow0}\left({1\over \sin x}-{1\over x}\right)

We need to change it to 00{0\over 0} first; it is equivalent to limx0xsinxxsinx=limx016x3xx=0\lim\limits_{x\rightarrow0}{x-\sin x\over x\sin x } = \lim\limits_{x\rightarrow0}{{1\over 6}x^3\over x x }=0

print('The limit of log(x)/(x-1) at x=1 is', limit(log(x)/(x-1), x=1))
The limit of log(x)/(x-1) at x=1 is 1
print('The limit of (x-sin(x))/x/sin(x) at x=0 is', limit((x-sin(x))/x/sin(x), x=0))
The limit of (x-sin(x))/x/sin(x) at x=0 is 0

Frequently Used Taylor Series

11x=1+x+x2++xn+=n=0xn,x<111+x=1x+x2+(x)n+=n=0(1)nxn,x<1ex=1+x+x22!++xnn!+=n=0xnn!,x<1sinx=xx33!+x55!+(1)nx2n+1(2n+1)!+=n=0(1)nx2n+1(2n+1)!,x<cosx=1x22!+x44!+(1)nx2n(2n)!+=n=0(1)nx2n(2n)!,x<ln(1+x)=xx22+x33+(1)n1xnn+=n=1(1)n1xnn, 1<x1tan1x=xx33+x55+(1)nx2n+12n+1+=n=0(1)nx2n+12n+1,x1\begin{align*}&{1\over 1-x}=1+x+x^2+\cdots+x^n+\cdots=\sum_{n=0}^\infty x^n, \quad |x|<1 \\ &{1\over 1+x}=1-x+x^2-\cdots+(-x)^n+\cdots=\sum_{n=0}^\infty (-1)^nx^n, \quad |x|<1 \\ &e^x=1+x+{x^2\over 2!}+\cdots+{x^n\over n!}+\cdots=\sum_{n=0}^\infty {x^n\over n!}, \quad |x|<1 \\ &\sin x = x -{x^3\over 3!}+{x^5\over 5!}-\cdots+(-1)^n{x^{2n+1}\over (2n+1)!}+\cdots=\sum_{n=0}^\infty {(-1)^nx^{2n+1}\over (2n+1)!},\quad |x|<\infty\\ &\cos x = 1 -{x^2\over 2!}+{x^4\over 4!}-\cdots+(-1)^n{x^{2n}\over (2n)!}+\cdots=\sum_{n=0}^\infty {(-1)^nx^{2n}\over (2n)!},\quad |x|<\infty\\ &\ln(1+x)= x -{x^2\over 2}+{x^3\over 3}-\cdots+(-1)^{n-1}{x^{n}\over n}+\cdots=\sum_{n=1}^\infty {(-1)^{n-1}x^{n}\over n},~ -1<x\leq 1\\ &\tan^{-1}x = x -{x^3\over 3}+{x^5\over 5}-\cdots+(-1)^n{x^{2n+1}\over 2n+1}+\cdots=\sum_{n=0}^\infty {(-1)^nx^{2n+1}\over 2n+1},\quad |x|\leq 1 \end{align*}
var('x') f = 1/(1-x) n = 6 print('The Taylor series of', f, 'starts with\n', f.taylor(x, 0, n)) f = 1/(1+x) print('\nThe Taylor series of', f, 'starts with\n', f.taylor(x, 0, n)) f = e^x print('\nThe Taylor series of', f, 'starts with\n', f.taylor(x, 0, n)) f = sin(x) print('\nThe Taylor series of', f, 'starts with\n', f.taylor(x, 0, n)) f = cos(x) print('\nThe Taylor series of', f, 'starts with\n', f.taylor(x, 0, n)) f = ln(1+x) print('\nThe Taylor series of', f, 'starts with\n', f.taylor(x, 0, n)) f = arctan(x) print('\nThe Taylor series of', f, 'starts with\n', f.taylor(x, 0, n))
The Taylor series of -1/(x - 1) starts with x^6 + x^5 + x^4 + x^3 + x^2 + x + 1 The Taylor series of 1/(x + 1) starts with x^6 - x^5 + x^4 - x^3 + x^2 - x + 1 The Taylor series of e^x starts with 1/720*x^6 + 1/120*x^5 + 1/24*x^4 + 1/6*x^3 + 1/2*x^2 + x + 1 The Taylor series of sin(x) starts with 1/120*x^5 - 1/6*x^3 + x The Taylor series of cos(x) starts with -1/720*x^6 + 1/24*x^4 - 1/2*x^2 + 1 The Taylor series of log(x + 1) starts with -1/6*x^6 + 1/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + x The Taylor series of arctan(x) starts with 1/5*x^5 - 1/3*x^3 + x