MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn...

59
MA4402 Computer Mathematics http://www.staff.ul.ie/natalia/MA4402.html Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12

Transcript of MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn...

Page 1: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

MA4402 Computer Mathematics

http://www.staff.ul.ie/natalia/MA4402.html

Natalia Kopteva

Autumn 2012

MA4402 (Autumn 2012) Computer Mathematics 0 / 12

Page 2: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Part 3 Sequences, Series, Power Series §3.0Motivation

One MA4402 Learning Outcome:

Employ sequences and series for an efficient representation ofmathematical functions in algorithms.

Part 3 Sequences, Series, Power Series 1 / 19

Page 3: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

MOTIVATION:

Computers, Calculators, Phones are all capable of performingbasic arithmetic operations cheaply and accurately.By basic arithmetic I mean +, −, × and /.Most of these devices can do much more than this. They cancalculate sin x and cos x , log x and ex .But HOW???NOTE: Evaluating these functions is a non-trivial task.Since sin x and cos x ... are not basic arithmetic operations, thecomputer must approximate them somehow.Moreover, whatever method is used to approximate them, it mustrely entirely on the four basic operations.

NOTE: There are a number of approaches to approximate thesefunctions, but we shall consider only one of them:

Power Series Representationof functions such as sin x and cos x

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .To prepare for this, we shall first consider Sequences and Series.

Part 3 Sequences, Series, Power Series 2 / 19

Page 4: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

§3.1 Sequences

DefinitionA sequence is an finite/infinite list of terms (or numbers) arranged in adefinite order, that is, there is a rule by which each term after the firstmay be found.

EXAMPLES:

1 {1,2,3,4,5, . . .}NOTE: the . . . at the end of a sequence indicates that we have aninfinite number of terms.

2 {1,4,9,16,25, . . .}NOTE: Denote the nth term by an.

Then a1 = 11 = 1, a2 = 22 = 4, a3 = 32 = 9...So this sequence can be described by the formula an = n2.

Part 3 Sequences, Series, Power Series 3 / 19

Page 5: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

3 Let a sequence be defined by the formula of its nth term:

an =

(1 +

1n

)n

.

Then we get a1 =

(1 +

11

)1

= 2, a2 =

(1 +

12

)2

=(3

2

)2,...

So we get

{2,

(32

)2

,

(43

)3

,

(54

)4

, . . .

}.

4 The Fibonacci sequence is defined as followsa1 = a2 = 1, an+2 = an + an+1.

From this definition we get: {1,1,2,3,5,8,13,21,34, . . .}.

Part 3 Sequences, Series, Power Series 4 / 19

Page 6: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

NOTATION: A sequence is frequently written as {a1,a2,a3,a4, . . .}.

Shorthand for such a sequence is {an}∞n=1

Another EXAMPLE: List the first 4 terms of the following sequence:an = n2 + 1.

Solution: The first four terms are a1, a2, a3 and a4.Therefore using the rule we get

a1 = (1)2 + 1 = 2; a2 = (2)2 + 1 = 5; a3 = (3)2 + 1 = 10;

a4 = (4)2 + 1 = 17.

Part 3 Sequences, Series, Power Series 5 / 19

Page 7: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

NOTE: one can use computer languages/packages to evaluate + plotgraphs of sequences. For example, the package Maple for an = 1 + 1

n :

Part 3 Sequences, Series, Power Series 6 / 19

Page 8: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Same example an = 1 + 1n , but now with a graph:

Part 3 Sequences, Series, Power Series 7 / 19

Page 9: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Bounded Sequences

DefinitionThe sequence {an} has a lower bound L if an > L for all n.

Examples:(i) The Fibonacci sequence has lower bound 1 as an > 1 for all n > 1.

(ii)The sequence {n2} has lower bound 1 as n2 > 1 for all n > 1.

DefinitionThe sequence {an} has an upper bound M if an 6 M for all n.

Example:The sequence {1 − 1

n } has upper bound 1 as 1 − 1n 6 1 for all n > 1.

Part 3 Sequences, Series, Power Series 8 / 19

Page 10: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

DefinitionThe sequence {an} is boundedif it has a lower bound L and an upper bound M

so L 6 an 6 M for all n.

Examples:

(i) an = sin(

n +1n

).

The sequence {an} is bounded as for all n > 1:

−1 6 sin(

n +1n

)6 1.

(ii) The sequence {2−n}∞n=1 is the sequence {12 ,

14 ,

18 , . . .}.

So it is bounded: 0 6 2−n 6 1.

Part 3 Sequences, Series, Power Series 9 / 19

Page 11: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Another EXAMPLE:

an =

{1 + 1

2n , if n is odd,

2n, if n is even.

From this definition we have:

a1 = 1 + 12 = 3

2 (here n = 1, odd);

a2 = 22 = 4 (here n = 2, even);

a3 = 1 + 123 = 1 + 1

8 = 98 (here n = 3, odd);

a4 = 24 = 16 (here n = 4, even); etc.

So we get the sequence: {32 ,4,

98 ,16, . . .}

This sequence has a lower bound 1 (as 1 + 12n > 1 and 2n > 1); but no

upper bound,

so it is not bounded.

Part 3 Sequences, Series, Power Series 10 / 19

Page 12: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Increasing/Decreasing Sequences, etc

DefinitionThe sequence {an} is

positive if an > 0 for all n.

negative if an 6 0 for all n.

increasing if an+1 > an for all n.

decreasing if an+1 < an for all n.

monotonic if it is either increasing or decreasing.

alternating if anan+1 < 0 for all n. i.e., consecutive terms haveopposite signs.

Part 3 Sequences, Series, Power Series 11 / 19

Page 13: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

NOTE: For a positive sequence, one can—replace the criterion an+1 > an by the equivalent an+1

an> 1;

—and the criterion an+1 < an by the equivalent an+1an

< 1.

EXAMPLES (Increasing/Decreasing Sequences)1 The sequence {an = n}∞n=1 is increasing

as an+1 − an = (n + 1) − n = 1 > 0.

2 The sequence {an = 1 − n}∞n=1 is decreasingas an+1 − an = (1 − (n + 1)) − (1 − n) = −1 < 0.

3 The positive sequence {an = 2n}∞n=1 is increasingas an+1

an= 2n+1

2n = 2 > 1.

4 The sequence {an}∞n=1 with an = 1+

(−1)n

n is neither increasing nordecreasingas we have {0, 3

2 ,23 ,

54 , . . .}.

(This sequence keeps bouncing backwards and forwards around1 and so neither increases nor decreases.)Part 3 Sequences, Series, Power Series 12 / 19

Page 14: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Limits of Sequences

DefinitionAs n→∞, the terms an may approach some number L.

Then we say that the sequence {an} converges to the limit L and writelim

n→∞an = L.

The series is said to be convergent.

Example: limn→∞ 1

n= 0; lim

n→∞(5 −

1n2

)= 5.

Part 3 Sequences, Series, Power Series 13 / 19

Page 15: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

DefinitionIf the sequence {an} does not converge to a finite limit, it is said to bedivergent.

Example: If an = n, then {an} diverges (as it goes to +∞.)

Part 3 Sequences, Series, Power Series 14 / 19

Page 16: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Further EXAMPLES:

1 If an = −2n, then {an} diverges (as it goes to −∞).

2 If an = (−1)n, then {an} = {−1,+1,−1,+1 . . .} just diverges.

Part 3 Sequences, Series, Power Series 15 / 19

Page 17: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Elementary Properties of Convergent SequencesSuppose lim

n→∞an = a and limn→∞bn = b.

(i) If cn = an + bn, then limn→∞ cn = a + b.

(ii) If cn = an × bn, then limn→∞ cn = a× b.

(iii) If cn = anbn

and b 6= 0, then limn→∞ cn =

ab

.

Example:Set an = 1 + 1

n and bn = 5 − 2n and check the above properties (i)–(iii).

NOTE: these properties will be used in all remaining Examples of thissection §3.1.

Part 3 Sequences, Series, Power Series 16 / 19

Page 18: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

NOTE: sequences such as 1n , 1

n2 , 1n3 , 1√

n converge to 0 as n→∞.

We shall use this observations in the next few examples.

Further EXAMPLES:

3 limn→∞ 7n − 5

2 + 3n= lim

n→∞ 7 − 5n

2n + 3

=7 − 00 + 3

=73

.

NOTE: we divided both the numerator and denominator by thestrongest term n

4 limn→∞ 3

√n − 1

8 − 5√

n=

Part 3 Sequences, Series, Power Series 17 / 19

Page 19: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Further EXAMPLES:

5 limn→∞ 2n2 − n − 1

5n2 + n − 3= lim

n→∞2 − 1

n − 1n2

5 + 1n − 3

n2

=2 − 0 − 05 + 0 + 0

=25

.

NOTE: we divided both the numerator and denominator by thestrongest term n2

Part 3 Sequences, Series, Power Series 18 / 19

Page 20: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Further EXAMPLES:

7 limn→∞ n2 − 5n4 + 10

3n2 + n − 7n4 = ...

8 limn→∞ n2 − 5n3 + 10

3n2 + n − 7n4 = ...

9 limn→∞ n2 − 5n4 + 10

3n2 + n − 7n3 = ...

Part 3 Sequences, Series, Power Series 19 / 19

Page 21: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

§3.2 Sequences in Root Algorithms

How are square roots computed on a computer??One possible way: define a sequence by a recursive rule.

Square Root√

p

a1 = 1, an+1 = 12

(an + p

an

)NOTE: this is in fact the Newton-Raphson Method applied to theequation x2 = p (whose positive root is

√p); see §4 for further details.

Particular Case√

2

a1 = 1, an+1 = 12

(an + 2

an

)Part 3 Sequences, Series, Power Series 1 / 6

Page 22: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXAMPLE: compute the first 3 terms in the√

2 algorithm.

a1 = 1,

a2 = 12

(a1 +

2a1

)= 1

2

(1 + 2

1

)= 3

2 ,

a3 = 12

(a2 +

2a2

)= 1

2

(32 + 2

3/2

)≈ 1.4166.

A SIMPLE COMPUTER CODE will produce as accurate anapproximation as required (see next page).

Part 3 Sequences, Series, Power Series 2 / 6

Page 23: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Part 3 Sequences, Series, Power Series 3 / 6

Page 24: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

QUESTION: how we can deduce from the recursive rule

an+1 = 12

(an + 2

an

)defining our sequence that it converges to

√2??

DISCUSSION:Assuming that the sequence {an} converges to some number L > 0,

i.e. limn→∞an = L ,

let n→∞ in the recursive rule:

limn→∞an+1 = lim

n→∞ 12

(an + 2

an

)L = 1

2

(L + 2

L

)so we have

2L = L + 2L ⇒ L = 2

L ⇒ L2 = 2 ⇒ L =√

2.

CONCLUSION: if the sequence {an} converges to some number L > 0,

then L =√

2

Part 3 Sequences, Series, Power Series 4 / 6

Page 25: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXERCISE: evaluate the first 4 terms in the√

3 sequence.

Solution:an+1 = 1

2

(an + 3

an

)So we get:

a1 = 1,

a2 =

a3 =

a4 =

Part 3 Sequences, Series, Power Series 5 / 6

Page 26: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXAMPLE: the sequence is defined by the recursive rulea1 = 1, an+1 = 1

4

(3an + 33

a3n

)Assuming that the sequence {an} converges to some number L > 0,find L.

Solution:

Answer: L = 4√

33

Part 3 Sequences, Series, Power Series 6 / 6

Page 27: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

§3.3 Series

A series is formed when the terms of a sequence are added together.

For example,2,5,8,11,14, · · · is an infinite sequence,but 2 + 5 + 8 + 11 + 14 + · · · is an infinite series.

Part 3 Sequences, Series, Power Series 1 / 15

Page 28: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

The Sigma Notation

The Sigma Notation:The Greek letter

∑(pronounced sigma), which means the sum of, is

generally used to express a series in a concise way.

Example: 2 + 4 + 8 + 16 + 32 = 2 + 22 + 23 + 24 + 25 =

5∑n=1

2n.

Note: 2n is the nth term in the sequence.Since we are summing the terms from 1 to 5 inclusive, the least valueof n is placed below the

∑sign and the greatest value of n is placed

above.

Part 3 Sequences, Series, Power Series 2 / 15

Page 29: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

NOTE: A finite series always ends with the last term even if severalmiddle terms are omitted:

Example:20∑

n=1

12n + 2

=14+

16+

18+ · · ·+ 1

42.

NOTE: An infinite series may also be written in sigma notation, where∞ is used to indicate that there is no upper limit for n:

Example: 2 + 4 + 6 + 8 + · · · =∞∑

n=1

2n.

Part 3 Sequences, Series, Power Series 3 / 15

Page 30: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXERCISE: Write the following series using∑

notation:

(i) 1 + 4 + 9 + 16 + · · ·+ 81

(ii) 1 − x + x2 − x3 + x4 − · · ·

(ii) −1 + 12x − 1

3x2 + 14x3 − 1

5x4 + · · ·

NOTE: In a series where the sign alternates from positive to negative,(−1)n may be used for the sign.

(−1)n results in even terms being positive and odd terms beingnegative.

(−1)n+1 results in even terms being negative and odd terms beingpositive.

Part 3 Sequences, Series, Power Series 4 / 15

Page 31: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Infinite Series

Definition (Infinite Series)Given a sequence {an}, the sum of all infinitely many terms in thissequence ∞∑

n=1

an = a1 + a2 + a3 + · · ·

is called an infinite series.

NOTE: it may be counterintuitive that we add infinitely many terms andstill can get a finite number, but this may be the case.

Part 3 Sequences, Series, Power Series 5 / 15

Page 32: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXAMPLE:

consider∞∑

n=1

1n2 = 1 +

122 +

132 +

142 +

152 + · · · .

Let us do the summation gradually: one term, then 2 terms, then 3terms, etc.:

S1 = 1 —this it the first term;S2 = 1 + 1

22 —this it the sum of first 2 terms;S3 = 1 + 1

22 + 132 —this it the sum of first 3 terms;

S4 = 1 + 122 + 1

32 + 142 —this it the sum of first 4 terms;

In general, Sn is the sum of the first n terms in our sequence:Sn = 1 + 1

22 + 132 + 1

42 + 152 + · · ·+ 1

n2

Part 3 Sequences, Series, Power Series 6 / 15

Page 33: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

For the series∞∑

n=1

1n2 = 1 +

122 +

132 +

142 +

152 + · · · ,

here are a few values of Sn obtained using a computer package:

Part 3 Sequences, Series, Power Series 7 / 15

Page 34: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

For the series∞∑

n=1

1n2 = 1 +

122 +

132 +

142 +

152 + · · · ,

plot a few values of Sn obtained using a computer package:

We see that as n→∞, the values Sn approach π2

6 ≈ 1.644934068.This implies that if we add all infinitely many terms of the sequence 1

n2 ,

we get∞∑

n=1

1n2 =

π2

6≈ 1.644934068

Part 3 Sequences, Series, Power Series 8 / 15

Page 35: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Definition (Convergent Infinite Series)Given a sequence {an}, let the sum of its first n terms

Sn =

n∑k=1

ak = a1 + a2 + a3 + · · ·+ an

If limn→∞Sn = S, where S is some real number, then we write∞∑

n=1

an = S and say that the series∞∑

n=1

an converges to the sum S.

NOTE: if limn→∞Sn is ±∞ or does not exist,

then we say that the series∞∑

n=1

an diverges.

Part 3 Sequences, Series, Power Series 9 / 15

Page 36: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXAMPLE of a DIVERGENT series: Harmonic Series

consider∞∑

n=1

1n= 1 +

12+

13+

14+

15+ · · · .

Let us do the summation gradually: one term, then 2 terms, then 3terms, etc.:

S1 = 1 —this it the first term;S2 = 1 + 1

2 —this it the sum of first 2 terms;S3 = 1 + 1

2 + 13 —this it the sum of first 3 terms;

S4 = 1 + 12 + 1

3 + 14 —this it the sum of first 4 terms;

In general, Sn is the sum of the first n terms in our sequence:Sn = 1 + 1

2 + 13 + 1

4 + 15 + · · ·+ 1

n

Part 3 Sequences, Series, Power Series 10 / 15

Page 37: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

For the series∞∑

n=1

1n= 1 +

12+

13+

14+

15+ · · · ,

here are a few values of Sn obtained using a computer package:

Part 3 Sequences, Series, Power Series 11 / 15

Page 38: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

For the series∞∑

n=1

1n= 1 +

12+

13+

14+

15+ · · · ,

plot a few values of Sn obtained using a computer package:

We see that as n→∞, the values Sn do not approach any finitenumber (no matter how large n we consider), but go to +∞.This implies that if we add all infinitely many terms of the sequence 1

n ,

we get +∞ so∞∑

n=1

1n

diverges

Part 3 Sequences, Series, Power Series 12 / 15

Page 39: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Further EXAMPLES:

1 Telescoping Series∞∑

n=1

1n(n + 1)

=1

1 · 2+

12 · 3

+1

3 · 4+ · · ·

2 Series∞∑

n=1

1 = 1 + 1 + 1 + 1 + · · ·

3 Geometric Series∞∑

n=1

12n−1 = 1 +

12+

14+

18+ · · ·

4 More general Geometric Series∞∑

n=1

xn−1 = 1+ x + x2 + x3 + · · ·

Part 3 Sequences, Series, Power Series 13 / 15

Page 40: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Geometric Series

Geometric series:∞∑

n=1

xn−1 = 1 + x + x2 + x3 + · · ·

Convergence/Divergence of Geometric Series

∞∑n=1

xn−1 = 1 + x + x2 + x3 + · · · ={ 1

1−x , if x ∈ (−1,1),divergent, otherwise

Proof:

Case (i): If x = 1, then∞∑

n=1

xn−1 = 1+x +x2 +x3 + · · · = 1+1+1+ · · ·

is divergent (see previous page).

Part 3 Sequences, Series, Power Series 14 / 15

Page 41: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Case (ii): Let x 6= 1. Then one can show that

Sn =

n∑k=1

xk−1 = 1 + x + x2 + · · · xn−1 =1 − xn

1 − x(Exercise!)

Now, if |x | < 1, then limn→+∞ xn = 0, so

limn→+∞ sn =

11 − x

.

Otherwise, limn→+∞ xn does NOT exist, so the series is divergent.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Example The rational number 0.323232323232 . . . can be representedas

0.32 + 0.0032 + 0.000032 + · · · = 32100

+32

1002 +32

1003 + · · ·

=32100

(1 +1

100+

11002 +

11003 + · · · ) = 32

100· 1

1 − 1100

=3299

.

Part 3 Sequences, Series, Power Series 15 / 15

Page 42: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

§3.4 Tests for Divergent/Convergent Series

Theorem If the series∑∞

n=0 an is convergent, then

limn→+∞an = 0.

From this we have

Divergence TestIf lim

n→+∞an 6= 0 then the series∑∞

n=0 an is divergent.

EXAMPLES:

(i) The series∞∑

n=1

(−1)n+1n = 1 − 2 + 3 − 4 + · · · is divergent as

limn→∞(−1)n+1n 6= 0;

(ii) The series∞∑

n=0

(−1)n = 1 − 1 + 1 − 1 + 1 + · · · is divergent as

limn→∞(−1)n 6= 0;

Part 3 Sequences, Series, Power Series 1 / 6

Page 43: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXAMPLES:

(iii) The series∞∑

n=0

n2n − 1

= 0 + 1 +23+

35+

47+ · · · is divergent as

limn→∞ n

2n − 1=

126= 0.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .NOTE: if limn→+∞ an = 0, the series may be divergent (see 3 aboveexamples), or convergent, such as the divergent series

∞∑n=1

1n= +∞.

(was considered earlier).

In other words, limn→+∞an = 0 is a necessary condition for the

convergence of∞∑

n=0

an, but NOT sufficient.

Part 3 Sequences, Series, Power Series 2 / 6

Page 44: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Ratio test

Ratio testLet∑

n an a series such that

limn→∞

∣∣∣∣an+1

an

∣∣∣∣ = p

If p < 1 the series is convergent.If p > 1 (or infinite) the series is divergent.If p = 1 the test is inconclusive.

NOTE: The ratio test is generally used to test for convergence ordivergence a series in which(i) the variable (generally n) appears in factorial form, e.g.,

∞∑n=0

3n!n + 1

(ii) the variable appears as a power, e.g.,∞∑

n=0

2n

n2

Part 3 Sequences, Series, Power Series 3 / 6

Page 45: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXAMPLES:

1

∞∑n=1

1n!

is convergent (p = 0 < 1)

2

∞∑n=1

2n

n2 is divergent (p = 2 > 1)

3

∞∑n=1

n5

3n is convergent (p = 13 < 1)

4

∞∑n=1

(2n)!(n!)2 is divergent (p = 4 > 1)

5

∞∑n=1

1nq (for some positive q) —test is inconclusive (p = 1);

Recall:∞∑

n=1

1n

is divergent, while∞∑

n=1

1n2 is convergent.

Part 3 Sequences, Series, Power Series 4 / 6

Page 46: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

6

∞∑n=0

10n

n!is convergent (as p = 0 < 1)

NOTE: this series converges to e10.

7

∞∑n=0

xn

n!is convergent for each x (as p = 0 < 1 for each fixed x)

(when we investigate convergence of the series, treat x as a fixedconstant)NOTE: this series converges to ex for each x .

Part 3 Sequences, Series, Power Series 5 / 6

Page 47: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

8

∞∑n=0

(2x)n

(n2 + 1)3n is convergent for |x | < 32 (as p =

|2x |3 < 1)

9

∞∑n=0

n!xn

is divergent for each x 6= 0 (as p =∞ > 1 for each fixed x 6= 0)

10 x −x2

2+

x3

3+ · · · =

∞∑n=1

(−1)n+1xn

nis convergent for each |x | < 1

(as p = |x | < 1 for each fixed |x | < 1)NOTE: this series converges to ln(1 + x) for each |x | < 1.

Part 3 Sequences, Series, Power Series 6 / 6

Page 48: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

§3.5 Functions as Infinite Power Series

Power SeriesA power series (about x = 0) is a series of the type:∞∑n=0

cnxn = c0 + c1x + c2x2 + · · ·,

where x is a variable, and c0, c1, · · · are given constants.

Exponential function: the power series representation is

ex =

∞∑n=0

xn

n!

NOTE: the Ratio Test shows (§3.4) that this series is convergent forany real x .

APPLICATION: one can use the sum of sufficiently many first terms

SN(x) =N∑

n=0

xn

n!to get an approximation of ex .

Then the evaluation of ex is reduced to basic operations (+, −, ×, /).Part 3 Sequences, Series, Power Series 1 / 12

Page 49: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

NOTE: one can use computer languages/packages to evaluate the

sum of sufficiently many first terms SN(x) = 1 + x +x2

2!+ · · ·+ xN

N!:

Part 3 Sequences, Series, Power Series 2 / 12

Page 50: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Consider the power series representation of ex : ex =

∞∑n=0

xn

n!

EXERCISE: Use the series and the following table to estimate thevalues of e0.5, e1.5 and e0.3 to 5 decimal places.

x = 0.5 x = 1.5 x = 0.3S0 = 1 1 1

S1 = 1 + x 1.5 2.5S2 = (1 + x) + x2

2! 1.625000000 3.625000000S3 = (1 + x + x2

2! ) +x3

3! 1.645833333 4.187500000S4 = S3 +

x4

4! 1.648437500 4.398437500S5 = S4 +

x5

5! 1.648697917 4.461718750S6 = S5 +

x6

6! 1.648719618 4.477539062S7 = S6 +

x7

7! 1.648721168 4.480929129S8 = S7 +

x8

8! — 4.481564767S9 = S8 +

x9

9! — 4.481670707S10 = S9 +

x10

10! — 4.481686598

Part 3 Sequences, Series, Power Series 3 / 12

Page 51: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

How one can get a power series representation??

QUESTION:How one can get a power series representation for any givenfunction??

ANSWER:There is a recipe called the Taylor series formula, which yields a powerseries representation for any function (no further details in this course).

Then one can use the Ratio test, to check where this power series isconvergent (i.e. where the power series is equal to the function ofinterest).

Part 3 Sequences, Series, Power Series 4 / 12

Page 52: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Further examples of power series representations

Trigonometric functions:

cos x =

∞∑n=0

(−1)nx2n

(2n)!= 1 −

x2

2!+

x4

4!+ · · ·

sin x =

∞∑n=0

(−1)nx2n+1

(2n + 1)!= x −

x3

3!+

x5

5!+ · · ·

NOTE: the Ratio Test shows (§3.4) that these series are convergent forany real x .

Important NOTE: x must be measured in radians, not in degrees(otherwise it doesn’t work).

Example: use cos(π3 ) = 1 −(π/3)2

2! +(π/3)4

4! + . . . to evaluate cos(π3 ) to3 decimal places.

Part 3 Sequences, Series, Power Series 5 / 12

Page 53: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

EXAMPLE: Evaluate sin(10o) to 5 decimal places.

SOLUTION:The angle should be represented in radians:

10o = 10o π1800 = π

18 ≈ 0.1745329252 radians.

Use the series representation: sin x = x − x3

3! +x5

5! + · · · withx = 0.1745329252.

Note: it is convenient to fill in a table of type:n an Sn0 · ·1 · ·2 · ·3 · ·4 · ·

Answer: 0.17364 (see next page)

Part 3 Sequences, Series, Power Series 6 / 12

Page 54: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Intermediate RESULTS for the previous example using a simple loop:

Part 3 Sequences, Series, Power Series 7 / 12

Page 55: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Hyperbolic Functions:

cosh x =

∞∑n=0

x2n

(2n)!= 1 +

x2

2!+

x4

4!+ · · ·

sinh x =

∞∑n=0

x2n+1

(2n + 1)!= x +

x3

3!+

x5

5!+ · · ·

NOTE: the Ratio Test shows (§3.4) that these series are convergent forany real x .

Part 3 Sequences, Series, Power Series 8 / 12

Page 56: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

QUESTION (Final Exam 2011):The hyperbolic cosine cosh(x) is a function defined by the series:

cosh(x) =+∞∑n=0

x2n

(2n)!

1 Use the ratio test to show that this series is convergent for all x .2 Use the series to estimate cosh(0.5) correct to 3 decimal places,

writing the partial sums in the following table.SOLUTION: (1) Ratio Test; (2) The Table:n an Sn0 · ·1 · ·2 · ·3 · ·4 · ·

Answer: 1.12 (see next page)

Part 3 Sequences, Series, Power Series 9 / 12

Page 57: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Intermediate RESULTS for the previous example using a simple loop:

Part 3 Sequences, Series, Power Series 10 / 12

Page 58: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

Log function in base e ' 2.7182818:

ln(1 + x) =∞∑

n=1

(−1)n+1xn

n= x −

x2

2+

x3

3−

x4

4+ · · ·

Inverse Tangent function:

tan−1 x =

∞∑n=0

(−1)nx2n+1

2n + 1= x −

x3

3+

x5

5−

x7

7+ · · ·

NOTE: the Ratio Test shows (§3.4) that these two series areconvergent for |x | < 1.

Part 3 Sequences, Series, Power Series 11 / 12

Page 59: MA4402 Computer Mathematics - University of Limerick Computer Mathematics Natalia Kopteva Autumn 2012 MA4402 (Autumn 2012) Computer Mathematics 0 / 12 Part 3 Sequences, Series, Power

How many terms??

QUESTION: How many terms in the power series representation of afunction one needs, to get certain accuracy / a certain number ofdecimal places correct??

Theoretical Approach:There is a theoretical estimate of the accuracy...Reference: the Lagrange remainder of the Taylor series.... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Heuristic Approach:If the addition of the next term in the series does NOT change thedecimal places of interest, one can STOP.

NOTE: how many terms one needs to compute an approximate valueof f (x) depends on the

(i) required accuracy; (ii) function f ; (iii) value x .

Part 3 Sequences, Series, Power Series 12 / 12