Recurrences, Part 3 Troy Vasiga Centre for Education in Mathematics - - PowerPoint PPT Presentation

recurrences part 3
SMART_READER_LITE
LIVE PREVIEW

Recurrences, Part 3 Troy Vasiga Centre for Education in Mathematics - - PowerPoint PPT Presentation

Recurrences, Part 3 Troy Vasiga Centre for Education in Mathematics and Computing Faculty of Mathematics, University of Waterloo cemc.uwaterloo.ca WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING Outline


slide-1
SLIDE 1

Recurrences, Part 3

Troy Vasiga Centre for Education in Mathematics and Computing Faculty of Mathematics, University of Waterloo cemc.uwaterloo.ca

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-2
SLIDE 2

Outline

  • Selected solutions to problems from last week
  • L-systems
  • Examples of L-systems
  • Prouhet-Thue-Morse sequence
  • Other definitions of PTM
  • Morphisms
  • Squares, cubes and overlaps
  • Summary

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-3
SLIDE 3

Solution to Problem 5

Use the Master Theorem to find the asymptotic running time for the recurrence T(n) = 4T(n/2) + n. Solution: We have a = 4, b = 2 and f (n) = n.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-4
SLIDE 4

Solution to Problem 5

Use the Master Theorem to find the asymptotic running time for the recurrence T(n) = 4T(n/2) + n. Solution: We have a = 4, b = 2 and f (n) = n. We calculate nlogb a = nlog2 4 = n2.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-5
SLIDE 5

Solution to Problem 5

Use the Master Theorem to find the asymptotic running time for the recurrence T(n) = 4T(n/2) + n. Solution: We have a = 4, b = 2 and f (n) = n. We calculate nlogb a = nlog2 4 = n2. Then, f (n) = n ∈ O(n2−ǫ for ǫ = 0.9 (for instance).

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-6
SLIDE 6

Solution to Problem 5

Use the Master Theorem to find the asymptotic running time for the recurrence T(n) = 4T(n/2) + n. Solution: We have a = 4, b = 2 and f (n) = n. We calculate nlogb a = nlog2 4 = n2. Then, f (n) = n ∈ O(n2−ǫ for ǫ = 0.9 (for instance). Thus, we are in case 1 of the Master Theorem, and thus T(n) = Θ(nlogb a) = Θ(n2).

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-7
SLIDE 7

Solution to Problem 7

Use the Master Theorem to find the asymptotic running time for the recurrence T(n) = 4T(n/2) + n3. Solution: We have a = 4, b = 2 and f (n) = n3. We calculate nlogb a = nlog2 4 = n2.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-8
SLIDE 8

Solution to Problem 7

Use the Master Theorem to find the asymptotic running time for the recurrence T(n) = 4T(n/2) + n3. Solution: We have a = 4, b = 2 and f (n) = n3. We calculate nlogb a = nlog2 4 = n2. Then, f (n) = n3 ∈ Ω(n3−ǫ) for ǫ = 1, for instance.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-9
SLIDE 9

Solution to Problem 7

Use the Master Theorem to find the asymptotic running time for the recurrence T(n) = 4T(n/2) + n3. Solution: We have a = 4, b = 2 and f (n) = n3. We calculate nlogb a = nlog2 4 = n2. Then, f (n) = n3 ∈ Ω(n3−ǫ) for ǫ = 1, for instance. Thus, we are in case 3 of the Master Theorem. We just need to verify that the second condition holds: that is, we need to show that af n b

  • ≤ cf (n)

for some fixed c for all n sufficiently large.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-10
SLIDE 10

Solution to Problem 7 (continued)

Plugging in our constants and f (n) = n3, we have to show: 4 n 2 3 ≤ cn3.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-11
SLIDE 11

Solution to Problem 7 (continued)

Plugging in our constants and f (n) = n3, we have to show: 4 n 2 3 ≤ cn3. Pick c = 1 and then for n > 1, we have: n3 2 ≤ cn3.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-12
SLIDE 12

Solution to Problem 7 (continued)

Plugging in our constants and f (n) = n3, we have to show: 4 n 2 3 ≤ cn3. Pick c = 1 and then for n > 1, we have: n3 2 ≤ cn3. Thus, by case 3 of the Master Theorem, T(n) = Θ(n3).

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-13
SLIDE 13

Definition of an L-system

An L-system or Lindenmayer system is a parallel rewriting system. By parallel, we mean we each step involves replacing every possible

  • ccurrence at the same time.

We also need to specify the starting condition/symbol.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-14
SLIDE 14

Rewriting Rules

We use the rule X → Y to mean “replace every occurrence of X with Y .” For example, if we have the rule X → ABX and we have the current word: ABXBAX then the next word will be

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-15
SLIDE 15

Rewriting Rules

We use the rule X → Y to mean “replace every occurrence of X with Y .” For example, if we have the rule X → ABX and we have the current word: ABXBAX then the next word will be ABABXBAABX

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-16
SLIDE 16

What does this sequence do?

  • 1. A → AB
  • 2. B → ǫ

(Here ǫ means “this disappears.”) Start with A

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-17
SLIDE 17

Not much

This just generates AB at the first step, which becomes AB after the second step, and so on. So, this is just the word AB.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-18
SLIDE 18

Not much

This just generates AB at the first step, which becomes AB after the second step, and so on. So, this is just the word AB. This indicates that AB is a fixed point of this recurrence.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-19
SLIDE 19

Not much

This just generates AB at the first step, which becomes AB after the second step, and so on. So, this is just the word AB. This indicates that AB is a fixed point of this recurrence. Definition: A fixed point of a function f is a value t such that f (t) = t.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-20
SLIDE 20

Not much

This just generates AB at the first step, which becomes AB after the second step, and so on. So, this is just the word AB. This indicates that AB is a fixed point of this recurrence. Definition: A fixed point of a function f is a value t such that f (t) = t. Notice: if f (t) = t, then f (f (t))

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-21
SLIDE 21

Not much

This just generates AB at the first step, which becomes AB after the second step, and so on. So, this is just the word AB. This indicates that AB is a fixed point of this recurrence. Definition: A fixed point of a function f is a value t such that f (t) = t. Notice: if f (t) = t, then f (f (t)) = f (t) =

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-22
SLIDE 22

Not much

This just generates AB at the first step, which becomes AB after the second step, and so on. So, this is just the word AB. This indicates that AB is a fixed point of this recurrence. Definition: A fixed point of a function f is a value t such that f (t) = t. Notice: if f (t) = t, then f (f (t)) = f (t) = t,

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-23
SLIDE 23

Not much

This just generates AB at the first step, which becomes AB after the second step, and so on. So, this is just the word AB. This indicates that AB is a fixed point of this recurrence. Definition: A fixed point of a function f is a value t such that f (t) = t. Notice: if f (t) = t, then f (f (t)) = f (t) = t, which means f n(t) = f (f (· · · f (t)) · · · ) = t.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-24
SLIDE 24

What does this sequence do?

  • 1. A → AB
  • 2. B → B

Start with A

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-25
SLIDE 25

Infinitely more

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-26
SLIDE 26

Infinitely more

After n iterations of the rewriting rules, we have the word ABn = ABB · · · B.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-27
SLIDE 27

What does this sequence do?

  • 1. A → B
  • 2. B → AB

Start with A. Hint: write out the first few terms and look at them.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-28
SLIDE 28

Fibonacci

Notice the length. Notice the ratio |A| |B|

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-29
SLIDE 29

What does this sequence do?

  • 1. A → ABA
  • 2. B → BBB

Start with A. Hint: draw a straight line.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-30
SLIDE 30

Cantor Dust

How much of the line is removed? What about the number 1

4 for instance?

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-31
SLIDE 31

What does this sequence do?

  • 1. X → X + YF
  • 2. Y → FX − Y

Start with FX.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-32
SLIDE 32

Dragon Curve

Do the following things:

  • F means move forward
  • + means turn clockwise 90o
  • − means turn counterclockwise 90o

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-33
SLIDE 33

Dragon Curve

Here are some steps:

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-34
SLIDE 34

Dragon Curve

Here are some steps:

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-35
SLIDE 35

Dragon Curve

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-36
SLIDE 36

Another L-system

Start with: F − −F − −F One rule: F → F + F − −F + F

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-37
SLIDE 37

Another L-system

Start with: F − −F − −F One rule: F → F + F − −F + F Let:

  • F: move forward
  • +: move clockwise by π

3

  • −: move counterclockwise by π

3

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-38
SLIDE 38

Koch Snowflake

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-39
SLIDE 39

What does this sequence do?

  • 1. 0 → 01
  • 2. 1 → 10

Start 0.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-40
SLIDE 40

Prouhet-Thue-Morse Sequence

It does lots of things. Call the sequence t = t0t1t2... = 0 1 1 0 1 0 0 1 ...

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-41
SLIDE 41

Draw a picture

  • If tn = 0, turn by π
  • If tn = 1, move ahead one unit and then rotate

counterclockwise by an angle of π

3 .

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-42
SLIDE 42

Koch Curve

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-43
SLIDE 43

Another definition of the PTM Sequence

Write out all integers in base-2 (i.e., binary). Define s2(x) to the sum of the digits in the base-2 representation

  • f x.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-44
SLIDE 44

Yet another definition of the PTM Sequence

Write the number, then flip the bits and rewrite it. Define: X0 = Xn+1 = Xn ¯ Xn where ¯ x means change all 0’s to 1’s, and 1’s to 0’s.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-45
SLIDE 45

Equivalent definitions

Prove that the last two definitions are equivalent. In other words, prove: tn = s2(n) mod 2 Proof: Use induction. Base case: n = 0. Assume true for all n < n′. Let k be the integer such that 2k ≤ n < 2k+1.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-46
SLIDE 46

Morphism

A morphism is a map h on strings that satisfies the identity h(xy) = h(x)h(y) for all strings x, y.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-47
SLIDE 47

PTM morphism

Define the PTM morphism µ(0) = 01, µ(1) = 10. Then µ(0) = 01

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-48
SLIDE 48

PTM morphism

Define the PTM morphism µ(0) = 01, µ(1) = 10. Then µ(0) = 01 µ2(0) = µ(µ(0)) = 0110

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-49
SLIDE 49

PTM morphism

Define the PTM morphism µ(0) = 01, µ(1) = 10. Then µ(0) = 01 µ2(0) = µ(µ(0)) = 0110 µ3(0) = 01101001 µ4(0) = 0110100110010110

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-50
SLIDE 50

Fixed point

The fixed point of a morphism h beginning with a is: hω(a) = lim

m→∞ hm(a).

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-51
SLIDE 51

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-52
SLIDE 52

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-53
SLIDE 53

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-54
SLIDE 54

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) =

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-55
SLIDE 55

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0))

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-56
SLIDE 56

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0)) =

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-57
SLIDE 57

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0)) = µk(01)

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-58
SLIDE 58

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0)) = µk(01) =

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-59
SLIDE 59

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0)) = µk(01) = µk(0)µk(1)

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-60
SLIDE 60

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0)) = µk(01) = µk(0)µk(1) =

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-61
SLIDE 61

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0)) = µk(01) = µk(0)µk(1) = Xk ¯ Xk

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-62
SLIDE 62

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0)) = µk(01) = µk(0)µk(1) = Xk ¯ Xk =

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-63
SLIDE 63

Equivalent definition

Let’s prove µn(0) = Xn. Use mathematical induction. Base case: n = 0. µ0(0) = 0 = X0. Assume the result holds for n = k. That is, µk(0) = Xk. Prove true for n = k + 1. µk+1(0) = µk(µ(0)) = µk(01) = µk(0)µk(1) = Xk ¯ Xk = Xk+1

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-64
SLIDE 64

Overlap-free

A square is a word of the form xx. A cube is a word of the form xxx. An overlap is a word axaxa, with a single letter a and x being any word. English word examples?

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-65
SLIDE 65

Overlap-free

A square is a word of the form xx. A cube is a word of the form xxx. An overlap is a word axaxa, with a single letter a and x being any word. English word examples? How does this relate to the Thue-Morse sequence?

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-66
SLIDE 66

What does this sequence converge to?

Consider the sequence: 1 2, 1/2 3/4,

1/2 3/4 5/6 7/8

,

1/2 3/4 5/6 7/8 9/10 11/12 13/14 15/16

What does this converge to?

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-67
SLIDE 67

Proof

First, observe the limit is: Πn≥0 2n + 1 2n + 2 (−1)tn Let: P = Πn≥0 2n + 1 2n + 2 (−1)tn Q = Πn≥0

  • 2n

2n + 1 (−1)tn Notice that PQ = 1 2Πn≥1

  • n

n + 1 (−1)tn

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-68
SLIDE 68

Proof

PQ = 1 2Πn≥1

  • n

n + 1 (−1)tn Rewrite, breaking over odd and even indices: PQ = 1 2Πn≥0 2n + 1 2n + 2 (−1)t2n+1 Πn≥1

  • 2n

2n + 1 (−1)tn = 1 2P−1Q. Thus, P2 = 1

2.

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING

slide-69
SLIDE 69

Summary

  • recursion is very natural
  • proving results using recursion is powerful
  • recursion has a self-contained, succinct form
  • recursion is beautiful

WWW.CEMC.UWATERLOO.CA | The CENTRE for EDUCATION in MATHEMATICS and COMPUTING