Download lecture02a

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Discrete Structures
Chapter 2 Part A
Sequences
Nurul Amelina Nasharuddin
Multimedia Department
Sequences
• Sequence is a set of (usually infinite number of)
ordered elements: a1, a2, …, an, …
• Eg: 2, 4, 6, 8, …
• Each individual element ak is called a term, where k is
called an index
• The example above denotes an infinite sequence
• Sequences can be computed using an explicit formula:
ak = k * (k + 1) for k > 1
a2 = 2 * (2 + 1) = 6, when k = 2
a3 = 3 * (3 + 1) = 12, when k = 3
a4 = 4 * (4 + 1) = 20, when k = 4
2
Sequences
• Finding an explicit formula given initial terms of
the sequence: 1, -1/4, 1/9, -1/16, 1/25, -1/36, …
1 (1) 1 (1) 1 (1)
, 2 , 2 , 2 , 2 , 2 ,...
2
1
2
3
4
5
6
a1
a2
a3
a4
a5
a6
• Ans: ak = (-1)k+1/ k2
• Sequence is (most often) represented in a
computer program as a single-dimensional array
3
Summation Operations
• Summation from k equals m to n, of ak where m 
Expanded form
n:
n
a
Summation
notation
k m
k
 am  am 1  am  2  ...  an
• Computing summation: Let a1 = -2, a2 = -1, a3 = 0
3
a
k 1
k
 a1  a2  a3  (2)  (1)  0  3
4
Summation Operations
• Changing from summation notation to expanded
n
form:
(1) i
 i 1
i 0
(1) 0 (1)1 (1) 2 (1) 3
(1) n




 ... 
0 1 11 2 1 3 1
n 1
1 1 1
(1) n
 1     ... 
2 3 4
n 1
• Changing from expanded form to summation
notation:
n
1
2
3
n 1
k 1


 ... 

n n 1 n  2
2n
k 0 n  k
5
Summation Operations
• Evaluating a1, a2, a3, …, an for small n:
1
1
1
1


 ... 
1.2 2.3 3.4
n(n  1)
• n=1? 1/(1.2) = 1/2
• n=2? 1/(1.2) + 1/(2.3) = 2/3
• n=3? 1/(1.2) + 1/(2.3) + 1/(3.4) = 3/4
• Recursive definition: If m and n are any integers
with m < n, then
m
n
n 1
 ak  am and  ak   ak an
k m
k m
k m
6
Summation Operations
• Separating off the final
1 n 1 1 1
 2  2

2
n
i 1 i
i 1 i
n
1
term:  i 2
i 1
n
n 1
• Adding on the final term:  2k  2n
k 0
n 1
2
k 0
n
k
 2   2k
n
k 0
• Telescoping sum: When writing sums in expanded
form, you sometimes see all the terms cancel
except for the first and last one.
7
Product Operations
• Product from k equals m to n of ak:
n
a
k
 am  am 1  am  2  ...  an
k m
• Recursive definition: If m and n are any integers
with m < n, then
m
n
n 1


and
a   a a
 ak  am
k m

k m
k

 k m
k


n
8
Factorial Notation
• n factorial: n! defined as the product of all integers
from 1 to n,
n! = n  (n – 1)  …  3  2  1
• Zero factorial: 0! = 1
• Simplify the factorials:
8! 8  7!

8
7!
7!
(n  1)! (n  1)  n!

 n 1
n!
n!
n!
n  (n  1)  (n  2)  (n  3)!

 n3  3n 2  2n
(n  3)!
(n  3)!
9
Properties
• If am, am+1, am+2, … and bm, bm+1, bm+2, … are
sequence of real numbers and c is any real
number, then the following equations hold for any
integer n  m:
n
n
n
 a   b   (a
k
k m
k m
k
n
n
k m
k m
k m
k
 bk )
c   ak   c  ak
 n
  n
 n
  ak     bk    (ak  bk )
 k m   k m  k m
10
Change of Variable
4
• Observe that:  ( j  2)
2
 (2  1) 2  (3  1) 2  (4  1) 2
j 2
3
1  2 3  k2
2
2
2
k 1
• Transform a sum by changing variable:
6
1
k 0 k  1
summation : 
change of variable : j  k  1
1. Calculate new lower and upper limits
When k = 0,
j = k + 1 = 0 + 1 = 1.
When k = 6,
j = k + 1 = 6 + 1 = 7.
The new sum goes from j = 1 to 7
11
Change of Variable
2. Calculate new general term
Since j = k + 1, then k = j – 1.
Hence
1
1
1


k  1  j  1  1 j
3. Finally put the steps together
6
7
1
1


k 0 k  1
j 1 j
12
Exercise
• Compute:
i (i  2)

i  2 (i  1)(i  1)
5
• Transform by making the change of variable
j = i – 1:
n 1
i
 (n  i )
i 1
2
Send in the answers on the next class!
13
Related documents