Topic 11 Infinite Sequences and Series
11.1 Introduction to Sequences and Series
A sequence is a list of numbers in a definite order (indexed by integers). A series may be considered as the limit of the sequence of partial sums.
When the sequence is explicitly defined by an mathematical expression an=f(n), Maple has the following command to list numbers of the sequence seq(f, i=m..n, step)
.
Example 11.1 Find the first 10 terms of the sequence {1n(n+1)}∞n=1. Determine whether the sequence {1n(n+1)} is convergent or divergent.
Solution.
# using seq
seq(1/(n*(n+1)), n=1..10)
The sequence converges to 0.
For a series ∑an, normally it is not easy to find explicit expression for the partial sum sn=n∑k=1ak. However, if sequence is defined by an mathematical expression an=f(n), we may find values of partial sums recursively use a for/from loop
statement in Maple:
for *counter* from *initial* by *increment* to *final* do
statement_sequence;
end do;
Example 11.2 Find the first 20 partial sums sk=∑nn=1an of the infinite series ∞∑n=012n=1+12+14+18+⋯. Determine whether the series ∑∞n=012n is convergent or divergent.
Solution.
# Set up s when n=0
s:=1
# Find 10 terms using `for/from loop`
for n from 1 to 10 do
s:=s+1/(2^n);
end do;
The series converges to 2.
Of course, we may also use for/from loop
to list numbers of a sequence.
Solution. Second solution to example 11.1.
# using `for/from loop`
for n from 1 to 10 do
1/(n*(n+1);
end do;
When the sequence is defined by a recurrence formula like the Fibonacci sequence, we will need to Maple how to interpret the formula. For that purpose, we use a procedure, which encloses a sequence of statements between proc(...)
and end proc
, to define the formula in Maple.
For example, the following is a procedure that defines a function a(x)=√x−1√x:
a:=proc(x) sqrt(x)-1/sqrt{x}; end proc;
To structure codes in a procedure, you may use Code Edit Region
which can be find in the Insert menu
.
To execute codes within this region, click Execute Code
from the Edit
menu, or use the shortcut command Ctrl+E
.
Example 11.3 The Fibonacci sequence is defined by fib(0)=0, fib(1)=1 and fib(n)=fib(n−1)+fic(n−2). Find the first 20 Fibonacci numbers.
Solution. We first define a function fib(n) which returns the n-th Fibonacci number.
fib := proc (n::nonnegint)
if 2 <= n then
return fib(n-1)+fib(n-2):
else
return n:
end if;
end proc
Now we can use either seq()
or for/from loop
.
seq(fib(n), n=0..19)
Exercise 11.1 Find the first 20 terms of the sequence {sinπn}∞n=1. Determine whether the sequence {sinπn} is convergent or divergent.
Exercise 11.2 Find the first 20 partial sums sk=∑nn=1an of the infinite series ∞∑n=01n=1+12+13+14+⋯. Determine whether the series ∑∞n=01n is convergent or divergent.
Exercise 11.3 Find the 20th to 30th Fibonacci numbers.
11.2 Power Series
A power series is a series with a variable x: ∞∑n=0cnxn=c0+c1x+c2x2+c3x3+⋯.
More generally, a series of the form
∞∑n=0cn(x−a)n=c0+c1(x−a)+c2(x−a)2+c3(x−a)3+⋯
is called a power series at a.
We call a positive number R the radius of convergence of the power series (11.1) if the power series converges whenever |x−a|<R and diverges whenever |x−a|>R.
If a function f has a power series representation, i.e. f(x)=∞∑n=0cn(x−a)n,|x−a|<R, then its coefficients are given by cn=f(n)(a)n!.
Example 11.4 Find the interval of convergence of the power series ∞∑n=1(−2)nxnn3.
Solution.
# Find the abs(a_{n+1}/a_n)
q:=abs((-2)^(n+1)(n+1)^3/(-2)^(n+1)(n+1)^3);
# Find the limit of q
r:=limit(simplify(q), n=infinity)
# Find the interval of convergence
solve(abs(x)<1/r, x)
Example 11.5 Find the Taylor expansion of the function f(x)=1x−2 at x=0 up to the 5-th order. Plot f(x) and the 5-th order Taylor polynomial together.
Solution.
# Find the Taylor expansion.
ftaylor:=taylor(1/(x-2), x = 0, 5)
# convert the Taylor series into a polynomial
fpoly:=convert(ftaylor, polynom)
# Plot the functions
plot([1/(x-2), fpoly], x=-1..1)
Exercise 11.4 Find the interval of convergence of the power series ∞∑n=1(−4)nxn√n.
Exercise 11.5 Find the Taylor expansion of the function f(x)=sinx at x=0 up to the 5-th order. Plot f(x) and the 5-th order Taylor polynomial together over the interval [−π,π].
11.3 Taylor Expansion
Let f(x) be a function. Assume that the k-th order derivatives fk(a) exist for k=1,2,…,n. The polynomial Tn(x)=n∑k=0f(n)(a)k!(x−a)k is called the n-th degree Taylor polynomial of f at a.
Let f(x) be a function has derivative at a up to all orders. Set Rn(x)=∞∑k=n+1f(k)(a)k!(x−a)k,|x−a|<R, which is called the reminder of the Taylor series ∞∑k=0f(k)(a)k!(x−a)k.
If lim for \left|x-a\right|<R, then f(x) is the sum of the Taylor series on the interval, that is f(x)=\sum\limits_{k=0}^\infty \dfrac{f^{(k)}(a)}{k!}(x-a)^k,\quad\quad \left|x-a\right|<R.
If \left|f^{n+1}{x}\right|\leq M for \left|x-a\right|\leq d, then the reminder R_n satisfies the follow inequality \left|R_n(x)\right|\leq \dfrac{M}{n+1}\left|x-a\right|^{n+1}\quad \text{for}\quad \left|x-a\right|\leq d.
Roughly speaking, the absolute value of the reminder \left|R_n(x)\right| determines how accurate the Taylor polynomial approximation.
Example 11.6 Approximate function f(x)=\sin x by the degree 3 Taylor polynomial at x=1.
Solution.
# Find the Taylor series.
fTs:=taylor(sin(x), x = 0, 4)
# Convert the Taylor series into a polynomial
fTp:=convert(fTs, polynom)
# Evaluate the Taylor polynomial at 1
subs(x=1, fpolyapprox)
Example 11.7 Plot the function g(x)=\begin{cases}e^{-\frac{1}{x^2}} & x\neq 0\\ 0 & x=0\end{cases} and its 5-th order Taylor polynomial over the domain [-2..2]. What can you conclude?
Solution.
# Define a piece-wisely defined function.
g:=piecewise(x!=0, exp(-1/x^2), 0)
# Find Taylor polynomial of degree 5.
for n to 5 do T := (eval(diff(g(x), x$n), x = 0))*x^n/factorial(n)+T end do
# Plot the functions
plot([g,T],x=-2..2, color=[red, blue])
The graphs of the functions are shown in the picture.

A non-analytic smooth function
In the solution, x$n
is a shortcut option for x, x, x, x, x
in the diff
command.
Exercise 11.6 Approximate function f(x)=e^x by the degree 5 Taylor polynomial at x=1.
Exercise 11.7 Compare the function y=\sin x with its degree 10 Taylor polynomial at x=0.