and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor...

94
Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Transcript of and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor...

Page 1: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrences, Graphs,and MatricesProfessor Lucas BangHarvey Mudd CollegeDepartment of Computer Science

Page 2: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

OverviewRecurrencesGraphsMatrices

3 powerful mathematical tools

1 super tool

Matrices Graphs

Recurrences

Page 3: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences

Page 4: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequencesordered lists of numbers1, 1, 1, 1, 1, 1, 1, 1, 1, 1, . . .

Page 5: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequencesordered lists of numbers1, 1, 1, 1, 1, 1, 1, 1, 1, 1, . . .1, 2, 3, 4, 5, 6, 7, 8, 9, 10, . . .

Page 6: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequencesordered lists of numbers1, 1, 1, 1, 1, 1, 1, 1, 1, 1, . . .1, 2, 3, 4, 5, 6, 7, 8, 9, 10, . . .2, 4, 6, 8, 10, 12, 14, 16, 18, 20, . . .

Page 7: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequencesordered lists of numbers1, 1, 1, 1, 1, 1, 1, 1, 1, 1, . . .1, 2, 3, 4, 5, 6, 7, 8, 9, 10, . . .2, 4, 6, 8, 10, 12, 14, 16, 18, 20, . . .1, 2, 4, 8, 16, 32, 64, 128, 256, 512, . . .

Page 8: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequencesordered lists of numbers1, 1, 1, 1, 1, 1, 1, 1, 1, 1, . . .1, 2, 3, 4, 5, 6, 7, 8, 9, 10, . . .2, 4, 6, 8, 10, 12, 14, 16, 18, 20, . . .1, 2, 4, 8, 16, 32, 64, 128, 256, 512, . . .2, 3, 5, 7, 11, 13, 17, 19, 23 . . .

Page 9: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequencesordered lists of numbers1, 1, 1, 1, 1, 1, 1, 1, 1, 1, . . .1, 2, 3, 4, 5, 6, 7, 8, 9, 10, . . .2, 4, 6, 8, 10, 12, 14, 16, 18, 20, . . .1, 2, 4, 8, 16, 32, 64, 128, 256, 512, . . .2, 3, 5, 7, 11, 13, 17, 19, 23 . . .1, 3, 6, 10, 15, 21, 28, 36, . . .

Page 10: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

Page 11: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one one

Page 12: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one one

Page 13: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one onetwo ones

Page 14: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one onetwo ones

Page 15: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one onetwo onesone two, one one

Page 16: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one onetwo onesone two, one one

Page 17: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one onetwo onesone two, one oneone one, one two, two ones

Page 18: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one onetwo onesone two, one oneone one, one two, two onesthree ones, two twos, one one

Page 19: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences111211211111221312211131122211113213211

one onetwo onesone two, one oneone one, one two, two onesthree ones, two twos, one one

Conway’s Look-and-Say Sequence

Page 20: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences

Neil Sloane Sloan’s Notebook

Page 21: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences

Page 22: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequences

Page 23: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Sequencesordered lists of numbers1, 1, 1, 1, 1, 1, 1, 1, 1, 1, . . .1, 2, 3, 4, 5, 6, 7, 8, 9, 10, . . .2, 4, 6, 8, 10, 12, 14, 16, 18, 20, . . .1, 2, 4, 8, 16, 32, 64, 128, 256, 512, . . .2, 3, 5, 7, 11, 13, 17, 19, 23 . . .1, 3, 6, 10, 15, 21, 28, 35, . . .

Page 24: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Starting from any number, nIf n is even, compute n2If n is odd, compute 3n + 1Repeat

Collatz Sequences

Page 25: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Starting from any number, nIf n is even, compute n2If n is odd, compute 3n + 1Repeat35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, . . .

Collatz Sequences

Page 26: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Starting from any number, nIf n is even, compute n2If n is odd, compute 3n + 1Repeat35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, . . .

Try this out, starting withn = your age

Collatz Sequences

Page 27: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Collatz SequencesCollatz’s Conjecture: starting from anynumber, the pattern always reaches therepeating sequence . . . , 4, 2, 1, . . .

Page 28: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Collatz SequencesCollatz’s Conjecture: starting from anynumber, the pattern always reaches therepeating sequence . . . , 4, 2, 1, . . .

Q: Is it true?

Page 29: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Collatz SequencesCollatz’s Conjecture: starting from anynumber, the pattern always reaches therepeating sequence . . . , 4, 2, 1, . . .

Q: Is it true?A: Nobody knows!

Page 30: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrences

Page 31: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

Page 32: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

Page 33: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

a0 = 0

Page 34: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

a0 = 0base case

Page 35: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

a0 = 0base casea1 = a0 + 2 = 0 + 2 = 2

Page 36: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

a0 = 0base casea1 = a0 + 2 = 0 + 2 = 2a2 = a1 + 2 = 2 + 2 = 4

Page 37: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

a0 = 0base casea1 = a0 + 2 = 0 + 2 = 2a2 = a1 + 2 = 2 + 2 = 4a3 = a2 + 2 = 4 + 2 = 6

Page 38: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

a0 = 0base casea1 = a0 + 2 = 0 + 2 = 2a2 = a1 + 2 = 2 + 2 = 4a3 = a2 + 2 = 4 + 2 = 6

In general,an = an−1 + 2

Page 39: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 0a1 = 2a2 = 4a3 = 6a4 = 8a5 = 10a6 = 12

a0 = 0base casea1 = a0 + 2 = 0 + 2 = 2a2 = a1 + 2 = 2 + 2 = 4a3 = a2 + 2 = 4 + 2 = 6

In general,an = an−1 + 2recurrence

Page 40: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 1a1 = 3a2 = 5a3 = 7a4 = 9a5 = 11a6 = 13

a0 = 1base casea1 = a0 + 2a2 = a1 + 2a3 = a2 + 2

an = an−1 + 2recurrence

Page 41: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 1a1 = 3a2 = 5a3 = 7a4 = 9a5 = 11a6 = 13

a0 = 1base casea1 = a0 + 2a2 = a1 + 2a3 = a2 + 2

an = an−1 + 2recurrence

Page 42: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 1a1 = 2a2 = 4a3 = 8a4 = 16a5 = 32a6 = 64

a0 = 1base casea1 = a0 × 2a2 = a1 × 2a3 = a2 × 2

an = an−1 × 2recurrence

Page 43: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencessequence numbers computed from earlier valuesa0 = 1a1 = 2a2 = 4a3 = 8a4 = 16a5 = 32a6 = 64

a0 = 1base casea1 = a0 × 2a2 = a1 × 2a3 = a2 × 2

an = an−1 × 2recurrence

Page 44: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesFibonacci NumbersF0 = 1F1 = 1F2 = 2F3 = 3F4 = 5F5 = 8F6 = 13

F0 = 1base casesF1 = 1F2 = F1 + F0F3 = F2 + F1

Fn = Fn−1 + Fn−2recurrence

F4 = F3 + F2

Page 45: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesFibonacci NumbersF0 = 1F1 = 1F2 = 2F3 = 3F4 = 5F5 = 8F6 = 13

F0 = 1base casesF1 = 1F2 = F1 + F0F3 = F2 + F1

Fn = Fn−1 + Fn−2recurrence

F4 = F3 + F2

Page 46: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbersL0 = 2L1 = 1L2 = 3L3 = 4L4 = 7L5 = 11L6 = 18

L0 = 2base casesL1 = 1

Fn = Fn−1 + Fn−2recurrence

Page 47: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Recurrencesmake up your own base casesQ0 =?base casesQ1 =?Qn = Qn−1 + Qn−2recurrence

Compute the first 10 values

Page 48: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1

Page 49: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1 1 ÷ 2 = 0.5

Page 50: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1L2 = 3

1 ÷ 2 = 0.53 ÷ 1 = 3

Page 51: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1L2 = 3L3 = 4

1 ÷ 2 = 0.53 ÷ 1 = 34 ÷ 3 = 1.3333

Page 52: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1L2 = 3L3 = 4L4 = 7

1 ÷ 2 = 0.53 ÷ 1 = 34 ÷ 3 = 1.33337 ÷ 4 = 1.75

Page 53: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1L2 = 3L3 = 4L4 = 7L5 = 11

1 ÷ 2 = 0.53 ÷ 1 = 34 ÷ 3 = 1.33337 ÷ 4 = 1.7511 ÷ 7 = 1.5714

Page 54: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1L2 = 3L3 = 4L4 = 7L5 = 11L6 = 18

1 ÷ 2 = 0.53 ÷ 1 = 34 ÷ 3 = 1.33337 ÷ 4 = 1.7511 ÷ 7 = 1.571418 ÷ 11 = 1.6364

Page 55: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1L2 = 3L3 = 4L4 = 7L5 = 11L6 = 18

1 ÷ 2 = 0.53 ÷ 1 = 34 ÷ 3 = 1.33337 ÷ 4 = 1.7511 ÷ 7 = 1.571418 ÷ 11 = 1.6364Try this for your sequence

Page 56: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

RecurrencesLucas numbers ratiosL0 = 2L1 = 1L2 = 3L3 = 4L4 = 7L5 = 11L6 = 18

1 ÷ 2 = 0.53 ÷ 1 = 34 ÷ 3 = 1.33337 ÷ 4 = 1.7511 ÷ 7 = 1.571418 ÷ 11 = 1.6364Try this for your sequence

Page 57: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matrices

Page 58: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

[6 8 44 1 3]

Matricesrectangular arrangements of numbers

Page 59: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

[6 8 44 1 3]

Matricesrectangular arrangements of numbers3 columns2 rows

Page 60: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

[3 12 7]

Matricesrectangular arrangements of numbers2 columns2 rows

Page 61: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7] + [8 23 2

] =adding two matrices[? ?? ?

]

Page 62: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7] + [8 23 2

] =adding two matrices[11 35 9

]add entries in the same positions

Page 63: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7] + [8 23 2

] =adding two matrices[11 35 9

]add entries in the same positions

Page 64: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[? ?? ?

]

Page 65: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]?

Page 66: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]3 × 2 + 1 × 0 = 6

?

Page 67: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]

Page 68: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]3 × 1 + 1 × 4 = 7

Page 69: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]3 × 1 + 1 × 4 = 7

Page 70: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]

Page 71: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]

Page 72: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]

Page 73: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]

Page 74: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[2 10 4

] =multiplying two matrices[6 74 30

]

Page 75: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[3 12 7]

×[37

] =multiplying a matrix by a single column matrix[1455

]

Page 76: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[1 11 0]

×[10

] =multiplying a matrix by a single column matrix[11

]

Page 77: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matricesrectangular arrangements of numbers

[1 11 0]

×[11

] =multiplying a matrix by a single column matrix[21

]

Page 78: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science
Page 79: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Graphs

Page 80: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

123

4

Bridges of KönigsbergGraphs

Page 81: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

123

4

Bridges of KönigsbergGraphs

Page 82: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

123

4

Bridges of KönigsbergGraphs$1 $1 $1

$1$1$1$1

Page 83: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

123

4

Bridges of KönigsbergGraphs$1 $1 $1

$1$1$1$1

Q: Starting from the north bank, how manydifferent bridge tours can I take for $4? (and I amhappy to see the same bridge more than once!)

Page 84: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Directed Graphsnodes connected by directed edges123

4

Page 85: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Directed Graphsnodes connected by directed edges123

4

$1 trips1 21 4

$2 trips1 21 2 131 2 41 4 3Q: how many $3 trips are there?

Page 86: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Directed Graphsnodes connected by directed edges123

4$2 trips1 21 2 131 2 41 4 3

1 2 11 2 1 24$3 trips

1 2 31 2 4 231 4 3 2

Page 87: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

$2 trips1 21 2 131 2 41 4 3

1 2 11 2 1 24$3 trips

1 2 31 2 4 231 4 3 2

$1 trips1 21 4

$# 1 2 3 4 52 4 5 ? ?Homework: Fill in 4 and 5. What insights doyou have? Is there any pattern to discover?

Page 88: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Directed Graphsnodes connected by directed edges

1 2A slight variation: how many tripsthat cost $n start and end at 1?

Page 89: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Matrices and Graphs[1 11 0

]1 2

Page 90: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

123

4

Matrices and Graphs

What does the matrix look like for the Königsberg graph?

Page 91: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Review

Matrices Graphs

Recurrences

[1 11 0] 1 2

Fn = Fn−1 + Fn−2

Page 92: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Review

Matrices Graphs

Recurrences

[1 11 0] 1 2

Fn = Fn−1 + Fn−2

Page 93: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science
Page 94: and Matrices Recurrences, Graphs,bang/gems/gems.pdf · Recurrences, Graphs, and Matrices Professor Lucas Bang Harvey Mudd College Department of Computer Science

Want to explore more?

These slides at www.cs.hmc.edu/∼bang