8.7. Sequences and Series#

Tip

Below is the list of topics that are covered in this section:

  • Sequences

  • Series

  • Convergence and Divergence of Series

  • Convergence Tests

  • Power Series

import matplotlib.pyplot as plt
import math

8.7.1. Sequences#

In this module, we define a sequence as an arrangement of an infinite number of numbers written in a specific order.

The common notations used for a sequence are {an}={an}n=1={a1,a2,}, where ai denote the ith term of the sequence.

Example

Write the first 5 terms of the following sequences:

  • {1n}=11,12,13,14,15,

  • {(1)n}n=0=1,1,1,1,1,

Some common sequences:

  • Arithmetic sequence: created by adding a certain constant d to the preceding term.

    • Using a1=a, the sequence is written explicitly: {a,a+d,a+2d,a+3d,}

    • Or, written recursively: {an} where a1=a and ai=ai1+d for i=2,3,.

  • Geometric sequence: created by multiplying a certain constant ratio r to the preceding term.

    • Using a1=a, the sequence is written explicitly: {a,ar,ar2,ar3,}

    • Or, written recursively: {an} where a1=a and ai=ai1r for i=2,3,.

  • Harmonic sequence: created by taking the reciprocal of an arithmetic sequence.

    • Using a1=1a, the sequence is written explicitly: {1a,1a+d,1a+2d,1a+3d,}

  • Fibonacci sequence: created by taking each term as the sum of the two preceding terms.

    • Written recursively: {an} where a1=0,a2=1, and ai=ai1+ai2 for i=3,4,

Properties of Sequences#

Given a sequence {an}.

  • {an} is increasing if an<an+1 for every n, also called monotonic increasing.

  • {an} is decreasing if an>an+1 for every n, also called monotonic decreasing.

  • {an} is monotonic nonincreasing (or monotonic nondecreasing) if {an} never increase (or decrease).

  • {an} is bounded below if there exist a number m such that man for every n. Here m is called a lower bound.

  • {an} is bounded above if there exist a number M such that Man for every n. Here M is called a upper bound.

  • {an} is bounded if it is both bounded below and bounded above.

Example

Determine if the given sequence is monotonic and/or bounded.

  • {an}={1n}

    • {an} is monotonic (decreasing) as 1n>1n+1 for every n.

    • {an} is bounded since 0an1 for every n. The first term is 1, value kept decreasing, but no matter how big n is, 1n is never negative.

  • {an}={(1)n}n=0

    • {an} is NOT monotonic since the sequence terms alternate between 1 and 1 so neither an increasing nor a decreasing sequence.

    • {an} is bounded since 1an1 for every n.

    • Note that the lower bound and upper bound are not unique. We can also said {an} is bounded since 35an708 for every n.

Below is an example code that plot the first 100 terms of the sequence {an}.

Hide code cell source
# Ask the user for the sequence
sequence = input("Enter the sequence {a_n}: ")

# Evaluate the sequence for the first 100 terms (can change the range as needed)
terms = []
for n in range(1, 101):
    term = eval(sequence, {'n': n})
    terms.append(term)

# Create the plot with dots
plt.scatter(range(1, 101), terms)
plt.xlabel("n")
plt.ylabel("a_n")
plt.title("Plot of the Sequence {a_n}")
plt.grid(True)

# Display the plot
plt.show()
../../_images/de3d46752af9d9141071515c2063f53ac139de5532f8486a8291671480edd94b.png

Limit of Sequences#

Recall limit notation from the Limit Section.

  • We say that limnan=L if for every number ε>0 there is an integer N such that |anL|<ε whenever n>N.

  • We say that limnan= if for every number M>0 there is an integer N such that an>M whenever n>N.

  • We say that limnan= if for every number M<0 there is an integer N such that an<M whenever n>N.

If limnan exists and is finite, we say {an} is convergent.

If limnan DNE or is infinite, we say {an} is divergent. If limnan=± then we say {an} diverges to ±.

Note that these limit definitions are not the same with monotonicity, which is stricter.

The use of an integer N whenever n>N emphasizes how limits only consider the end part of a sequence, not necessarily for every n like in monotonicity. For example:

  • The sequence {an}={2,5,60,700,8000,43,521,1,70,500,2,1,1,1,1,1,1,1,} (the rest of the terms are all 1).>

    • {an} is not monotonic, but limnan=1 since at some point, all the term goes to 1.

  • The sequence {an}={35,75,42,21,12,1,2,3,4,5,6,} (the rest of the terms keep going down by 1).

    • {an} is not monotonic decreasing, but limnan= since at some point the term kept going down.

Properties of limits of sequences follow from the properties of limits, so will not be relisted in this section.

Theorems#

Below are some useful theorems on sequences. Motivated students are encouraged to prove them.

Theorems

Theorem 1: If {an} is monotonic and bounded, then {an} is convergent.

Theorem 2: If limn|an|=0 then limnan=0.

Theorem 3: The sequence {rn}n=0 converges to 0 if 1<r<1, converges to 1 if r=1, and diverges for all other values of r.

Theorem (Squeeze Theorem for Sequences): If ancnbn for all n>N for some integer N and limnan=limnbn=L, then limncn=L.

While the theorems are useful, it is also useful to be able to check the convergence or divergence of a sequence using Python code. Below is a code that checked the first 100 terms of {an} to determine whether {an} converges or diverges. It is easy to change the number of terms to check if needed.

Hide code cell source
# Ask the user for the sequence
sequence = input("Enter the sequence a_n: ")

# Evaluate the first 100 terms of the sequence
terms = []
for n in range(1, 101):
    term = eval(sequence, {'n': n, 'math': math})
    terms.append(term)

# Check if the sequence converges or diverges
converges = all(term == terms[0] for term in terms)
if converges:
    print("The sequence converges.")
else:
    print("The sequence diverges.")
The sequence diverges.

8.7.2. Series#

(Infinite) series are an infinite sum of terms a1+a2+a3+, typically written using sigma notation i=1ai.

Example

  • i=1i=1+2+3+4+

  • i=12i=21+22+23+24+

  • i=13i4i=3141+3242+3343+3444+

The i in i=1ai is called the index (of summation), not to be confused with the notation of imaginary numbers.

  • What letter used to represent the index does not matter: i=1ai=k=1ak=n=1an, etc.

  • For convenience, index shift can be applied to series: i=1ai=i=2a(i1)=i=0a(i+1), etc.

    • With this in mind, it is normal for different resources and math literatures to define series with index started with i1.

Example

  • i=11i2=112+122+132+=k=11k2

  • i=11i2=112+122+132+=i=51(i4)2

8.7.3. Convergence and Divergence of Series#

The nth partial sums of i=1ai is the finite sum Sn=i=1nai=ai+a2++an.

The series i=1ai is convergent if the sequence of partial sums {Sn}n=1 is convergent to a finite limit.

The series i=1ai is divergent if the sequence of partial sums {Sn}n=1 is divergent.

Example

  • i=11i2+i is convergent since limnSn=limn(i=1n1i2+i)=limn(i=1n1i(i+1))=limn(i=1n1i1i+1)=limn(11n)=1.

  • i=1i is divergent since limnSn=limn(i=1ni)=limn(n(n+1)2)=.

Properties of Convergent Series#

If i=kai and i=kbi are both convergent, then

  • i=kcai=ci=kai is also convergent for any constant c.

  • i=kai±i=kbi=i=k(ai±bi) is also convergent.

Recall distributive property to note that (i=1ai)(i=1bi)i=1(aibi). In fact, (i=1ai)(i=1bi)=i=1ci where ci=k=1iakb(ik).

No conclusions can be drawn about the convergence or multiplication of series. Moreover, given how complicated the multiplication of infinite series is, people would rather avoid doing it.

Theorems

Theorem: If n=1an converges then limnan=0.

Theorem (Divergence Test): If limnan0 then n=1an diverges.

Example The series i=13i2+57ii2 diverges since limn3n2+57nn2=30.

Geometric Series#

A geometric series is a series that can be written in the form i=1ari1, or, with index shift, i=0ari.

The nth partial sum Sn of a geometric series can be found as follows:

SnrSn=(a+ar+ar2+ar3++arn1)(ar+ar2+ar3++arn1+arn)(1r)Sn=aarnSn=a(1rn)1r

Taking the limit of the sequence of partial sums:

limnSn=limna(1rn)1r=limn(a1rarn1r)=limna1rlimnarn1r=a1ra1rlimnrn

The only term depending on n is rn, which only provides finite answers 1<r1. However, r=1 gives division by zero on the a1r, and the limit only exists (and equals zero) when 1<r<1 (or, |r|<1). Thus, the limit of the partial sums, as well as the sum of the geometric series, is i=1ari1=limnSn=a1ra1r0=a1r.

Example

Determine if n=12n+23n1 converge or diverge. If it converges, give the value of the series.

The convergence of this series can be seen by rewriting it in geometric series form and calculating:

n=12n+23n1=n=1232n13n1=n=18(23)n1=8123=813=24.

Harmonic Series#

A harmonic series is the series i=11i. Remember that if n=1an converges then limnan=0, but not the other way around. While limn1n=0, the Harmonic series is divergent. This will be shown with the Integral Test below.

8.7.4. Convergence Tests#

Integral Test#

If f(x) is a continuous, positive, and decreasing function on the interval [k,) and that f(i)=ai, then,

  • if kf(x)dx is convergent then i=kai is also convergent.

  • if kf(x)dx is divergent then i=kai is also divergent.

Example: Harmonic Series

Note that f(x)=1x is a continuous, positive and decreasing function on [1,).

Since 11xdx= and hence is divergent, then by the Integral test, the Harmonic series i=11i also divergent.

The p-series Test#

If k>0 then then i=k1ip converges if p>1 and diverges if p1.

Example

i=21i5 converges as it is a p-series with p=5>1, while i=21i diverges as it is a p-series with p=0.5<1.

Comparison Test#

Given two series ai and bi with nonnegative ai and bi for all i. If aibi for all i, then:

  • If bi is convergent then ai is also convergent

  • If ai is divergent then bi is also divergent

Example

  • i=1i3+2i75 is convergent, because i3+2i75>i3+2i7>i3i7=1i4 and i=11i4 is convergent as it is a p-series with p=4>1.

  • i=1ii2+7 is divergent, because ii2+7<ii2=1i and i=11i is divergent as it is a p-series with p=1.

Limit Comparison Test#

Given two series ai and bi with ai0 and bi>0 for all i. Define c=limiaibi.

If 0<c<, then either both ai and bi converge or both ai and bi diverge.

Limit Comparison Test (LCT) is similar to the Comparison Test (CT) in the sense that we want to compare the series with a series that we know or easily recognize as converging or diverging.

Example

Is i=11i+2i convergent or divergent?

Take 1i+2i as bi and 12i as ai so that c=limi12i1i+2i=limii+2i2i=limii2i+limi1=limi12iln(2)+1=1.

As c=1 is finite positive and i=112i is convergent for being a geometric series with |r|=|12|<1, then by LCT, i=11i+2i is also convergent.

Alternating Series Test#

Suppose ai is a series with ai=(1)ibi or ai=(1)i+1bi where bi0 for all i.

If limibi=0 and {bi} is a decreasing sequence, then ai is convergent.

Example

Determine if i=3sin(iπ)i is convergent or divergent.

Note that sin(iπ)=(1)i hence we can rewrite the series into i=3(1)ii, which is in the alternating form with bi=1i.

Since limibi=limi1i=0 and 1i>1i+1 for all i3, then the Alternating Series Test conditions are satisfied and hence i=3sin(iπ)i is convergent.

Absolute and Conditional Convergence#

The series i=1ai is absolutely convergent if i=1ai converges and n=i|ai| converges.

The series i=1ai is conditionally convergent if i=1ai converges but n=i|ai| diverges.

It immediately follows that absolute convergence implies convergence, but not vice versa.

Example

i=1(1)nn is conditionally convergent:

  • i=1(1)nn is convergent by the Alternating Series Test

  • i=1|(1)nn|=i=11n since it’s a Harmonic series (by the Integral Test).

Ratio Test#

Given the series ai. Define L=limi|ai+1ai|=limi|ai+11ai|.

  • If L<1 then the series is absolutely convergent, and hence convergent

  • If L>1 then the series is divergent

  • If L=1 then the test is inconclusive

Example

  • i=1i2(2i)! is absolutely convergent since

L=limi|(i+1)2(2(i+1))!(2i)!i2|=limi|(i+1)2(2i)!i2(2i+2)!|=limi(i+1)2(2i)!i2(2i+2)(2i+1)(2i!)=limi(i+1)2i2(2i+2)(2i+1)=0<1.
  • i=1i!2i is divergent since L=limi|(i+1)!2i+12ii!|=limii+12=>1.

  • Ratio Test fails for determining convergence of i=11i2 since L=limi|(i+1)2i2|=limii2+2i+1i2=limi1+2i+1i2=1.

    • However, we knew from p-test that i=11i2 is convergent.

Root Test#

Given the series ai. Define L=limi|ai|i=limi|ai|1/i.

  • If L<1 then the series is absolutely convergent, and hence convergent

  • If L>1 then the series is divergent

  • If L=1 then the series is inconclusive

In using the Root Test, we often use the fact that limnn1/n=1.

Example

  • i=1(34i25i2+6)i is absolutely convergent since L=limi|(34i25i2+6)i|1i=limi|34i25i2+6|=|45|=45<1.

  • i=12ii is divergent since L=limi|2ii|1i=limi2i1/i=21>1.

  • The Root Test fails for determining convergence of i=11i since L=limi|1i|1i=limi1i1/i=11=1.

    • However, we already know that this Harmonic series is divergent.

Convergence Test with Python#

While multiple tests can be used to manually determine the convergence of a series with steps that can become complicated, in Python, testing the convergence of a series is built in.

Below is a code that ask for an and return the convergence of n=1. The lower bound n=1 can be changed as needed.

Hide code cell source
# Ask the user for the sequence
sequence = input("Enter the sequence a_n: ")

# Define the symbol n
n = sp.Symbol('n')

# Define the series sum(a_n) from n=1 to infinity
series = sp.Sum(eval(sequence), (n, 1, sp.oo))

# Check if the series is convergent or divergent
if series.is_convergent():
    print("The series is convergent.")
else:
    print("The series is divergent.")
The series is convergent.

8.7.5. Power Series#

A power series (about a) is a series that can be written in the form i=0ci(xa)i where a and ci are constants. The ci’s are called the coefficient of the power series.

Since power series are a function of x, the convergence of the series depends on the values of x.

The radius of convergence of a power series is the number R such that the series will converge for |xa|<R and diverge for |xa|>R. The series may or may not converge if |xa|=R.

The interval of convergence is the interval containing all values of x in which a power series converges, hence it’s the interval (aR,a+R) possibly combined with the endpoint aR and/or a+R.

Example

Determine the radius and interval of convergence for i=02i(x2)ii.

Using Ratio Test: L=limi|2i+1(x2)i+1i+1i2i(x2)i|=limi|2i(x2)i+1|=2|x2|limiii+1=2|x2|.

By Ratio Test, i=02i(x2)ii converges when 2|x2|<1|x2|<0.5.

Hence the radius of convergence is 0.5.

For the interval of convergence, solving for x from |x2|<0.51.5<x<2.5, so we are left to check for the endpoints:

  • at x=1.5, the sum is i=02i(1.52)ii=i=02ii(12)i=i=0(1)ii, which converges by the Alternating Series Test.

  • at x=2.5, the sum is i=02i(2.52)ii=i=02ii(12)i=i=01i, which diverges since it is a Harmonic series.

Thus, the interval of convergence is 1.5x<2.5.

8.7.6. Exercises#

Exercises

  1. List the first 5 terms of each given sequence, then determine whether each sequence is monotonic and/or bounded.

    • {nn+1}n=1

    • {2n21n}n=2

  2. Determine whether the following sequences converge or diverge. Determine the limit if it exists.

    • {(1)nn35n4}n=0

    • {e3n2+en}n=1

    • {ln(n+6)ln(3+3n)}n=1

  3. Index shift and rename exercise:

    • Write i=15ii3 as a series that starts at n=3.

    • Write i=5(1)i+22i as a series that starts at k=1.

  4. Determine the convergence of the following series:

    • i=11iπ/4

    • i=1i1i4+2

    • i=1(1)i+2i3+2i+2

  5. Determine the interval and radius of convergence of the following series:

    • i=142i+151+i(x+3)i

    • i=1(i+1)(2i+1)!(x2)i