1. February 5, Applied Discrete Mathematics 1
…… and now for…and now for…
SequencesSequences
2. February 5, Applied Discrete Mathematics 2
SequencesSequences
SequencesSequences representrepresent ordered listsordered lists of elements.of elements.
AA sequencesequence is defined as a function from a subset ofis defined as a function from a subset of
NN to a set S. We use the notation ato a set S. We use the notation ann to denote theto denote the
image of the integer n. We call aimage of the integer n. We call ann a term of thea term of the
sequence.sequence.
Example:Example:
subset ofsubset of NN: 1 2 3 4 5 …: 1 2 3 4 5 …
S: 2 4 6 8 10 …S: 2 4 6 8 10 …
3. February 5, Applied Discrete Mathematics 3
SequencesSequences
We use the notation {aWe use the notation {ann} to describe a sequence.} to describe a sequence.
Important: Do not confuse this with the {} used in setImportant: Do not confuse this with the {} used in set
notation.notation.
It is convenient to describe a sequence with aIt is convenient to describe a sequence with a
formulaformula..
For example, the sequence on the previous slideFor example, the sequence on the previous slide
can be specified as {acan be specified as {ann}, where a}, where ann = 2n.= 2n.
4. February 5, Applied Discrete Mathematics 4
The Formula GameThe Formula Game
1, 3, 5, 7, 9, …1, 3, 5, 7, 9, … aann = 2n - 1= 2n - 1
-1, 1, -1, 1, -1, …-1, 1, -1, 1, -1, … aann = (-1)= (-1)nn
2, 5, 10, 17, 26, …2, 5, 10, 17, 26, … aann = n= n22
+ 1+ 1
0.25, 0.5, 0.75, 1, 1.25 …0.25, 0.5, 0.75, 1, 1.25 … aann = 0.25n= 0.25n
3, 9, 27, 81, 243, …3, 9, 27, 81, 243, … aann = 3= 3nn
What are the formulas that describe theWhat are the formulas that describe the
following sequences afollowing sequences a11, a, a22, a, a33, … ?, … ?
5. February 5, Applied Discrete Mathematics 5
StringsStrings
Finite sequences are also calledFinite sequences are also called stringsstrings, denoted, denoted
by aby a11aa22aa33…a…ann..
TheThe lengthlength of a string S is the number of terms thatof a string S is the number of terms that
it consists of.it consists of.
TheThe empty stringempty string contains no terms at all. It hascontains no terms at all. It has
length zero.length zero.
6. February 5, Applied Discrete Mathematics 6
SummationsSummations
It represents the sum aIt represents the sum amm + a+ am+1m+1 + a+ am+2m+2 + … + a+ … + ann..
The variable j is called theThe variable j is called the index of summationindex of summation,,
running from itsrunning from its lower limitlower limit m to itsm to its upper limitupper limit n.n.
We could as well have used any other letter toWe could as well have used any other letter to
denote this index.denote this index.
∑=
n
mj
jaWhat does stand for?What does stand for?
7. February 5, Applied Discrete Mathematics 7
SummationsSummations
It is 1 + 2 + 3 + 4 + 5 + 6 = 21.It is 1 + 2 + 3 + 4 + 5 + 6 = 21.
We write it as .We write it as .∑=
1000
1
2
j
j
What is the value of ?What is the value of ?∑=
6
1j
j
It is so much work to calculate this…It is so much work to calculate this…
What is the value of ?What is the value of ?∑=
100
1j
j
How can we express the sum of the first 1000How can we express the sum of the first 1000
terms of the sequence {aterms of the sequence {ann} with a} with ann=n=n22
forfor
n = 1, 2, 3, … ?n = 1, 2, 3, … ?
8. February 5, Applied Discrete Mathematics 8
SummationsSummations
It is said that Friedrich Gauss came up with theIt is said that Friedrich Gauss came up with the
following formula:following formula:
∑=
+
=
n
j
nn
j
1 2
)1(
When you have such a formula, the result of anyWhen you have such a formula, the result of any
summation can be calculated much more easily, forsummation can be calculated much more easily, for
example:example:
5050
2
10100
2
)1100(100100
1
==
+
=∑=j
j
9. February 5, Applied Discrete Mathematics 9
Double SummationsDouble Summations
Corresponding to nested loops in C or Java,Corresponding to nested loops in C or Java,
there is also double (or triple etc.) summation:there is also double (or triple etc.) summation:
Example:Example:
∑∑= =
5
1
2
1i j
ij
∑=
+=
5
1
)2(
i
ii
∑=
=
5
1
3
i
i
451512963 =++++=
10. February 5, Applied Discrete Mathematics 9
Double SummationsDouble Summations
Corresponding to nested loops in C or Java,Corresponding to nested loops in C or Java,
there is also double (or triple etc.) summation:there is also double (or triple etc.) summation:
Example:Example:
∑∑= =
5
1
2
1i j
ij
∑=
+=
5
1
)2(
i
ii
∑=
=
5
1
3
i
i
451512963 =++++=