Download Slide 1

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

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

Document related concepts

Infinity wikipedia , lookup

Big O notation wikipedia , lookup

Functional decomposition wikipedia , lookup

Non-standard calculus wikipedia , lookup

Karhunen–Loève theorem wikipedia , lookup

Abuse of notation wikipedia , lookup

Numerical continuation wikipedia , lookup

Structure (mathematical logic) wikipedia , lookup

Elementary mathematics wikipedia , lookup

Large numbers wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Hyperreal number wikipedia , lookup

Factorial wikipedia , lookup

Sequence wikipedia , lookup

Collatz conjecture wikipedia , lookup

Recurrence relation wikipedia , lookup

Transcript
RECURRENCE
1.
2.
3.
Sequence
Recursively defined sequence
Finding an explicit formula for
recurrence relation
1
Learning Outcomes

You should be able to solve
first-order and second-order linear
homogeneous recurrence relation with
constant coefficients
2
Preamble

What is recurrence and how does it
relate to a sequence?
3
Sequences

A sequence is an ordered list of objects (or events). Like a set,
it contains members (also called terms)
Sequences can be finite or infinite.

2,4,6,8,…

for i ≥ 1
ai = 2i (explicit formula)
infinite sequence with infinite distinct values

-1,1,-1,1,…
for i ≥ 1
bi = (-1)i
infinite sequence with finite distinct values

For
1<=i<=6
ci = i+5
finite sequence (with finite distinct values)
6,7,8,9,10,11
4
Ways to define sequence




Write the first few terms:
3,5,7,…
Use explicit formula for its nth term
an = 2n for n ≥ 1
Use recursion
How to define a sequence using a
recursion?
5
Recursively defined sequences
Recursion can be used to defined a sequence.
This requires:
A recurrence relation: a formula that relates each term ak
to some previous terms ak-1, ak-2, …
ak = ak-1 + 2ak-2
The initial conditions: the values of the first few terms a0, a1, …
Example: For all integers k ≥ 2, find the terms b2, b3 and b4:
bk = bk-1 + bk-2 (recurrence relation)
b0 = 1 and b1 = 3 (initial conditions)
Solution:
b2 = b1 + b0 = 3 + 1 = 4
b3 = b2 + b1 = 4 + 3 = 7
b4 = b3 + b2 = 7 + 4 = 11
6
Explicit formula and
recurrence relation

Show that the sequence 1,-1!,2!,-3!,4!,…,(-1)nn!,…
for n≥0, satisfies the recurrence relation
sk = (-k)sk-1 for all integers k≥1.
The general term of the sequence: sn=(-1)nn!
substitute k and k-1 for n to get
sk=(-1)kk! sk-1=(-1)k-1(k-1)!
Substitute sk-1 into recurrence relation:
(-k)sk-1 = (-k)(-1)k-1(k-1)!
= (-1)k(-1)k-1(k-1)!
= (-1)(-1)k-1 k(k-1)!
= (-1)k k! = sk
7
Examples of recursively
sequence
Famous recurrences
Arithmetic sequences: ak = ak-1 + d
e.g. 1,4,7,10,13,…
geometric sequences: ak = ark-1
e.g. 1,3,9,27,…
Factorial: f(n) = n . f(n-1)
Fibonacci numbers: fk = fk-1+fk-2
1,1,2,3,5,8,…
Tower of Hanoi problem

8
Tower of Hanoi
9
10
11
12
Application of recurrence

Analysis of algorithm containing recursive function such as
factorial function.
Algorithm f(n)
/input: A nonnegative integer
/output: The value of n!
If n = 0 return 1
else return f(n-1)*n


No. of operations (multiplication) determines the efficiency of
algo.
Recurrence relation is used to express the no. of operation in
the algorithm.
13
Solving Recurrence relation by
Iteration



It is helpful to know an explicit formula for a
sequence.
An explicit formula is called a solution to the
recurrence relation
Most basic method is iteration
- start from the initial condition
- calculate successive terms until a pattern
can be seen
- guess an explicit formula
14
Some examples
Let a0,a1,a2,… be the sequence defined recursively as follows: For
all integers k≥1,
(1) ak = ak-1+2
(2) a0 = 1
Use iteration to guess an explicit formula for the sequence.
a0=1
a1=a0+2
a2=a1+2=(1+2)+2 = 1+2.2
a3=a2+2=(1+2.2)+2 = 1+3.2
a4=a3+2=(1+3.2)+2 = 1+4.3
….
Guess: an=1+n.2=1+2n
The above sequence is an arithmetic sequence.
15
Geometric Sequence
Let r be a fixed nonzero constant, and suppose a sequence
a0,a1,a2,… is defined as follows:
ak = rak-1 for all integers k ≥ 1
a0 = a
Use iteration to guess an explicit formula for the sequence
a0=a
a1=ra0=ra
a2=ra1=r(ra)=r2a
a3=ra2=r(r2a)=r3a
Guess: an=rna = arn for all integers n≥0
The above sequence is geometric sequence and r is a common
ratio.
16
17
Explicit formula for tower of Hanoi





mn = 2n – 1. (exponential order)
To move 1 disk takes 1 second
m64 = 264 –1 = 1.844674 * 1019 seconds
= 5.84542 * 1011 years
= 584.5 billion years.
18
Second-Order Linear Homogeneous with
constant coefficients

A second-order linear homogeneous
recur. relation with c.c. is a recur.
relation of the form
ak = Aak-1 + Bak-2 for all integers k ≥
some fixed integer,
where A and B are fixed real numbers
with B ≠ 0.
19
Terminology





ak = Aak-1 + Bak-2
Second order: ak contains the two previous
terms
Linear: ak-1 and ak-2 appear in separate terms
and to the first power
Homogeneous: total degree of each term is
the same (no constant term)
Constant coefficients: A and B are fixed real
numbers
20
Examples






Second-Order Linear Homogeneous with constant
coefficients
ak = 3ak-1 + 2ak-2 - yes.
bk = bk-1 + bk-2 + bk-3 - no
dk = (dk-1)2 + dk-1dk-2 - no; not linear
ek = 2ek-2 - yes; A = 0, B = 2.
fk = 2fk-1 + 1 - no; not homogeneous
21
Distinct-Roots Case
22