Sequences and Logic - Fordham University

Download Report

Transcript Sequences and Logic - Fordham University

CSRU 1100
Structures of
Computer Science
JMH 112
Mon/Thurs 11:30-12:45pm
Spring 2009
C. Schweikert
Sequences
What number comes next?
1, 2, 3, 4, 5, ____
6
2, 6, 10, 14, 18, ____ 22
1, 2, 4, 8, 16, ____
32
What comes next?
2, 5, 10, 17, 26, 37, ____ 50
1, 2, 6, 24, 120, ____
2, 3, 5, 8, 12, ____
720
17
1, 1, 2, 3, 5, 8, 13, ____ 21
The key to any sequence is to discover
its pattern
• The pattern could be that each term is somehow
related to previous terms
• The pattern could be described by its relationship to
its position in the sequence (1st, 2nd, 3rd etc…)
• You might recognize the pattern as some well known
sequence of integers (like the evens, or multiples of
10).
• You might be able to do all three of these ways!
2, 4, 6, 8, 10 …
• Can we define a given element in relation to previous
elements.
– The first element has to be 2 since it has no previous
elements
– The second element is 2 more than the first element
– The third element is 2 more than the second element.
– In fact, each subsequent element is just two more than the
previous one.
2, 4, 6, 8, 10 …
• Can we represent this sequence in relation to
its position?
– At position 1 the value is 2
– At position 2 the value is 4
– At position 3 the value is 6
– At position n the value is 2 * n
2, 4, 6, 8, 10 …
• Do we recognize this sequence as
something familiar?
–Yes. It is the positive even numbers.
Mathematical Notation
• When we want to refer to terms in a sequence
we usually use lower case letters (a, b, …)
followed by a subscript indicating the position
in the sequence we are referring to.
• a1
is the first term in a sequence
• a2
is the second term in a sequence
• an
is the nth term in a sequence
2, 4, 6, 8, 10 …
•
•
•
•
•
2
What is a1?
What is a3?
6
10
What is a5?
What is an if n = 4?
What is an-1 if n = 4?
8
6
Recursive Formula
• A recursive formula for a sequence is one
where each term is described in relation to a
previous term (or terms)
2, 4, 6, 8, 10 …
Write each term in relation to its prior term (as a
recursive formula)
• What is a1?
a1=2 (no prior terms)
• What is a3?
a3= a2+ 2
• What is a5?
a5= a4+ 2
• What is an?
an= an-1+ 2
Closed Formula
• A closed formula for a sequence is a formula
where each term is described only by its
relation to its position.
2, 4, 6, 8, 10 …
Write each term in relation to its position (as a
closed formula)
• What is a1?
a1=1* 2 (no prior terms)
• What is a3?
a3= 3 * 2
• What is a5?
a5= 5 * 2
• What is an?
an = n * 2
Let’s try another
• Consider the sequence
5, 9, 13, 17…
• Write a recursive formula for this
sequence. a =5
1
an= an-1 + 4
•Write a closed formula for this sequence
an= 4n + 1
And another
1, 3, 7, 15, 31, 63…
Making a table can help to get a feel for what’s going on.
1
2
3
4
5
6
n
1
3
7
15 31 63 ?
The recursive formula actually isn’t
too bad.
• a1=1
• an= 2an-1 + 1
The closed formula is a little bit
harder this time.
an  2 1
n
Now try your hand at these.
Find both recursive and closed formulas for
the following sequences.
2, 6, 10, 14, 18, ____
1, 2, 4, 8, 16, ____
1, 2, 6, 24, 120, ____
2, 6, 10, 14, 18, ____
Recursive Formula
b1  2
bn  bn1  4
Closed Formula
bn  n  4  2
1, 2, 4, 8, 16, ____
Recursive Formula
c1  1
cn  2cn1
Closed Formula
( n1)
cn  2
1, 2, 6, 24, 120, ____
Recursive Formula
d1  1
d n  d n1  n
Closed Formula
d n  n!
Find a recursive formula from a
closed formula
an  7n  6
First write out the first several terms so you can
understand the sequence
1
2
3
4
5
1
8
15
22
29
Find a recursive formula from a
closed formula
an  7n  6
Establish the starting point in the pattern and then
determine how each value relates the prior value
a1  1
an  an1  7
Find a closed formula from a
recursive formula
a1  2
an  3an1  1
These tend to be harder but you still want to
establish and understand the sequence
1
2
3
4
5
2
7
22
67
202
Find a closed formula from a
recursive formula
a1  1
an  3an1  1
At this point unless you are really clever we
are kind of stuck, the pattern is not one you
may recognize. Specialized methods are
needed to complete these.
Common Mathematical Notion
• Summation: A summation is just the sum of
the terms in a sequence.
• If the terms in the sequence are
– 1, 2, 3, 4, 5, 6 then the summation is
– 1+2+3+4+5+6 = 21
• If the terms in the sequence are
– 1, 4, 9, 16, 25 then the summation is
– 1+4+9+16+25 = 55
Summation is a very common Idea
• Because it is so common,
mathematicians have developed a
shorthand to represent summations
(also called sigma notation)
n
i
i 1
This is what the shorthand looks like, on
the next few slides we will dissect it a bit.
Dissecting Sigma Notation
n
i

i 1
The giant Sigma just
means that this represents
a summation
Dissecting Sigma Notation
n
i

i 1
The i=1 at the bottom just
states where is the
sequence we want to start.
If the value was 5 then we
would start the sequence
at the 5th position
Dissecting Sigma Notation
n
i

i 1
The n at the top just says
to what element in the
sequence we want to get
to. In this case we want to
go up through the nth
item.
Dissecting Sigma Notation
n
i

i 1
The portion to the right of
the sigma is the closed
formula for the sequence
you want to sum over.
Dissecting Sigma Notation
n
i

i 1
So this states that we want
to compute the closed
formula for each element
from 1 to n.
Dissecting Sigma Notation
n
i

i 1
The portion to the right of
the sigma is the closed
formula for the sequence
you want to sum over.
Dissecting Sigma Notation
n
i

i 1
Thus our summation is
1+2+3+…+n
If I told you that n had the value
of 5, then the summation would
be
1 + 2 + 3 + 4 + 5 = 15
Let’s try a few. Compute the
following summations
5
 (i  2)
 3 4  5  6  7  25
i 1
7
 (i
i 1
2
 1)  2  5  10  17  26  37  50  147
How would you write the following
sums using sigma notation?
8
5+10+15+20+25+30+35+40
  (5i )
i 1
6
1+8+27+64+125+216
  (i )
3
i 1
So why are sequences important
• Identifying patterns is an essential tool for
anyone
• Developing a vocabulary to represent and
analyze these sequences is the key to speaking
the language of mathematics.