Oh No! More on Fractals. The Koch Family of Curves. Unary and Binary. Homework #1 is due today at 11:59pm Give yourself sufficient time to make PDF

Similar documents
Mathathon Round 1 (2 points each)

Homework 1 from Lecture 1 to Lecture 10

Lecture Overview. 2 Weak Induction

Homework Gots to be Typeset. We Are Here to help! Dominoes. Inductive Reasoning Lecture 2 (January 19, 2006)

Organization Team Team ID#

Making Math: A Hands on History Beth Powell

Hence, the sequence of triangular numbers is given by., the. n th square number, is the sum of the first. S n

Math Round. Any figure shown may not be drawn to scale.

CS1800 Discrete Structures Final Version A

Senior Math. Binary numbers are based on the powers of 2: 2 0 = 1, 2 1 = 2, 2 2 = 4, 2 3 = 8, 2 4 = 16, Binary numbers use only two digits: 0 and 1

Solution Set 4, Fall 12

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015

Grade 8 Chapter 7: Rational and Irrational Numbers

Consider an infinite row of dominoes, labeled by 1, 2, 3,, where each domino is standing up. What should one do to knock over all dominoes?

During: The Pythagorean Theorem and Its converse

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010

Great Theoretical Ideas in Computer Science

What is proof? Lesson 1

Math Circle: Recursion and Induction

Discrete Mathematics. Spring 2017

Finite and Infinite Sets

Prompt. Commentary. Mathematical Foci

{ 0! = 1 n! = n(n 1)!, n 1. n! =

Pascal s Triangle Introduction!

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

Induction 1 = 1(1+1) = 2(2+1) = 3(3+1) 2

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

Notes on counting. James Aspnes. December 13, 2010

Grade 6 Math Circles November 1 st /2 nd. Egyptian Mathematics

FINITE ABELIAN GROUPS Amin Witno

CS1800: Sequences & Sums. Professor Kevin Gold

CIS Spring 2018 (instructor Val Tannen)

, p 1 < p 2 < < p l primes.

D I S C R E T E M AT H E M AT I C S H O M E W O R K

Cpt S 223. School of EECS, WSU

Outline. We will cover (over the next few weeks) Induction Strong Induction Constructive Induction Structural Induction

All numbered readings are from Beck and Geoghegan s The art of proof.

Discrete Mathematics U. Waterloo ECE 103, Spring 2010 Ashwin Nayak May 17, 2010 Recursion

Ancient Wisdom: Primes, Continued Fractions, The Golden Ratio, and Euclid s GCD

Fractals. Justin Stevens. Lecture 12. Justin Stevens Fractals (Lecture 12) 1 / 14

AMA1D01C Egypt and Mesopotamia

Fall 2016 Test 1 with Solutions

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016

CS 2110: INDUCTION DISCUSSION TOPICS

4 a b 1 1 c 1 d 3 e 2 f g 6 h i j k 7 l m n o 3 p q 5 r 2 s 4 t 3 3 u v 2

CMSC250 Homework 9 Due: Wednesday, December 3, Question: Total Points: Score:

MATH10040: Numbers and Functions Homework 1: Solutions

Some Review Problems for Exam 2: Solutions

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

1 What is the area model for multiplication?

Discrete Mathematics & Mathematical Reasoning Induction

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

Review 3. Andreas Klappenecker

MATH 3330 ABSTRACT ALGEBRA SPRING Definition. A statement is a declarative sentence that is either true or false.

1 Sequences and Summation

Notes for Recitation 14

3.1 Induction: An informal introduction

CS 4349 Lecture August 30th, 2017

1 Reductions from Maximum Matchings to Perfect Matchings

Complex Numbers: A Brief Introduction. By: Neal Dempsey. History of Mathematics. Prof. Jennifer McCarthy. July 16, 2010

Recurrence Relations and Difference Tables! CSCI 2824, Fall 2012!

5.2 Infinite Series Brian E. Veitch

Generating Functions

Preparing for the CS 173 (A) Fall 2018 Midterm 1

International Mathematics TOURNAMENT OF THE TOWNS

Topic 1: 2D Motion PHYSICS 231

Alpha Sequences and Series FAMAT State Convention 2017

What if the characteristic equation has complex roots?

One-to-one functions and onto functions

History of Mathematics

Intermediate Mathematics League of Eastern Massachusetts

Sums and Products. a i = a 1. i=1. a i = a i a n. n 1

Math 31 Lesson Plan. Day 5: Intro to Groups. Elizabeth Gillaspy. September 28, 2011

2005 Euclid Contest. Solutions

Chapter Generating Functions

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 3. Θ Notation. Comparing Algorithms

MATH 2200 Final Review

CS 340: Discrete Structures for Engineers

Math 300: Final Exam Practice Solutions

Grade 11/12 Math Circles Fall Nov. 12 Recurrences, Part 3

Math Homework 5 Solutions

MADHAVA MATHEMATICS COMPETITION, December 2015 Solutions and Scheme of Marking

Discrete Structures May 13, (40 points) Define each of the following terms:

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Homework 5. This homework is due October 6, 2014, at 12:00 noon.

Group. Orders. Review. Orders: example. Subgroups. Theorem: Let x be an element of G. The order of x divides the order of G

Chapter One. Quadratics 20 HOURS. Introduction

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

CDM. Recurrences and Fibonacci. 20-fibonacci 2017/12/15 23:16. Terminology 4. Recurrence Equations 3. Solution and Asymptotics 6.

MAC-CPTM Situations Project

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1

Traces and Ancient Egypt

Egyptian Fraction. Massoud Malek

USA Mathematical Talent Search Round 2 Solutions Year 27 Academic Year

Why do we need math in a data structures course?

USA Mathematical Talent Search Round 3 Solutions Year 20 Academic Year

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course

Lecture 8 : Structural Induction DRAFT

Summer Packet A Math Refresher For Students Entering IB Mathematics SL

Transcription:

Great Theoretical Ideas In Computer Science Danny Sleator Lecture 3 CS 15-251 Jan 19, 2010 Spring 2010 Carnegie Mellon University Unary and Binary Oh No! Homework #1 is due today at 11:59pm Give yourself sufficient time to make PDF Quiz #1 is next Thursday during lecture More on Fractals Fractals are geometric objects that are selfsimilar, i.e. composed of infinitely many pieces, all of which look the same. The Koch Family of Curves

Fractal Dimension We can break a line segment into N selfsimilar pieces, and each of which can be magnified by a factor of N to yield the original segment. Fractal Dimension The dimension is the exponent of the number of self-similar pieces with magnification factor into which the figure may be broken. We can break a square into N 2 self-similar pieces, and each of which can be magnified by a factor of N. Hausdorff dimension Fractal Dimension of the Plane We can break a square into N 2 self-similar pieces, and each of which can be magnified by a factor of N. Fractal Dimension of the Koch Curve We begin with a straight line of length 1 Remove the middle third of the line, and replace it with two lines that each have the same length Repeat infinitely

Fractal Dimension of the Koch Curve The Koch Family of Curves 60 o 1 What if we increase that angle but keep all sides of the equal length? 72 o Compute its dimension! The Koch Family of Curves The Koch Family of Curves 1 72 o A B C D 1 72 o A B C D Increase this angle AD = 2 + BC BC = 2 cos(72 o ) 90 o A B C D Plane-filling curve

Unary and Binary How to play the 9 stone game? 1 2 3 4 5 6 7 8 9 9 stones, numbered 1-9 Two players alternate moves. Each move a player gets to take a new stone Any subset of 3 stones adding to 15, wins. Magic Square: Brought to humanity on the back of a tortoise from the river Lo in the days of Emperor Yu in ancient China Magic Square: Any 3 in a vertical, horizontal, or diagonal line add up to 15. 4 9 2 3 5 7 8 1 6

Conversely, any 3 that add to 15 must be on a line. TIC-TAC-TOE on a Magic Square Represents The Nine Stone Game Alternate taking squares 1-9. Get 3 in a row to win. Basic Idea of This Lecture Don t stick with the representation in which you encounter problems! Always seek the more useful one! This idea requires a lot of practice Prehistoric Unary 1 2 3 4

Consider the problem of finding a formula for the sum of the first n numbers You already used induction to verify that the answer is!n(n+1) 1 + 2 + 3 + + n-1 + n = S n + n-1 + n-2 + + 2 + 1 = n+1 + n+1 + n+1 + + n+1 + n+1 = 2S S n(n+1) = 2S A different approach 1 + 2 + 3 + + n-1 + n = S n + n-1 + n-2 + + 2 + 1 = S n th Triangular Number! n = 1 + 2 + 3 +... + n-1 + n n(n+1) = 2S = n(n+1)/2 There are n(n+1) dots in the grid! n....... 2 1 1 2........ n

n th Square Number n = n 2 =! n +! n-1 Breaking a square up in a new way Breaking a square up in a new way 1 1 + 3 Breaking a square up in a new way

1 + 3 + 5 Breaking a square up in a new way 1 + 3 + 5 + 7 Breaking a square up in a new way 1 + 3 + 5 + 7 + 9 =? 1 + 3 + 5 + 7 + 9 = 5 2 Breaking a square up in a new way Breaking a square up in a new way

The sum of the first n odd numbers is n 2 Here is an alternative dot proof of the same sum. Pythagoras n th Square Number n th Square Number n =! n +! n-1 = n 2 n =! n +! n-1 = n 2

n th Square Number n th Square Number n =! n +! n-1 n =! n +! n-1 = Sum of first n odd numbers Area of square = (! n ) 2 We find a formula for the sum of the first n cubes.! n =n (n+1)/2! n

Area of square = (! n ) 2 Area of square = (! n ) 2! n-1?! n-1 n! n-1! n =n (n+1)/2! n-1! n =n (n+1)/2? n! n! n Area of square = (! n ) 2 Area of square = (! n ) 2 = (! n-1 ) 2 + n! n-1 + n! n = (! n-1 ) 2 + n(! n-1 +! n ) = (! n-1 ) 2 + n(n 2 )! n-1 n! n-1 n = (! n-1 ) 2 + n 3! n-1! n-1 (! n-1 ) 2! n n! n! n n n n! n-1! n! n

(! n ) 2 = n 3 + (! n-1 ) 2 = n 3 + (n-1) 3 + (! n-2 ) 2 (! n ) 2 = 1 3 + 2 3 + 3 3 + +n 3 = [ n(n+1)/2 ] 2 = n 3 + (n-1) 3 + (n-2) 3 + (! n-3 ) 2 = n 3 + (n-1) 3 + (n-2) 3 + + 1 3 Can you find a formula for the sum of the first n squares? Rhind Papyrus Scribe Ahmes was Martin Gardner of his day! Babylonians needed this sum to compute the number of blocks in their pyramids

Rhind Papyrus 1 + X 1 + X 2 + X 3 + + X n-2 + X n-1 = X n 1 X - 1 A man has 7 houses, Each house contains 7 cats, Each cat has killed 7 mice, Each mouse had eaten 7 ears of spelt, Each ear had 7 grains on it. What is the total of all of these? Sum of powers of 7 What is a closed form of the sum of powers of integers? We ll use this fundamental sum again and again: The Geometric Series Proof Geometric Series for x=2 (X-1) ( 1 + X 1 + X 2 + X 3 + + X n-2 + X n-1 ) = X 1 + X 2 + X 3 + + X n-1 + X n - 1 - X 1 - X 2 - X 3 - - X n-2 - X n-1 = X n - 1 (when x! 1)

Geometric Series for x=! Two Case Studies Bases and Representation BASE X Representation S = a n-1 a n-2 a 1 a 0 represents the number: Bases In Different Cultures a n-1 X n-1 + a n-2 X n-2 +... + a 0 X 0 Sumerian-Babylonian: 10, 60, 360 Base 2 [Binary Notation] 101 represents: 1 (2) 2 + 0 (2 1 ) + 1 (2 0 ) = Base 7 015 represents: 0 (7) 2 + 1 (7 1 ) + 5 (7 0 ) Egyptians: 3, 7, 10, 60 Maya: 20 Africans: 5, 10 French: 10, 20 English: 10, 12, 20 =

BASE X Representation S = ( a n-1 a n-2 a 1 a 0 ) X represents the number: a n-1 X n-1 + a n-2 X n-2 +... + a 0 X 0 Largest number representable in base-x with n digits = (X-1 X-1 X-1 X-1 X-1 X-1) X = (X-1)(X n-1 + X n-2 +... + X 0 ) = (X n 1) Fundamental Theorem For Binary Each of the numbers from 0 to 2 n -1 is uniquely represented by an n-bit number in binary k uses " log 2 (k+1) # = $ log 2 k % + 1 digits Fundamental Theorem For Base X Each of the numbers from 0 to X n -1 is uniquely represented by an n- digit number in base X k uses $ log X k % + 1 digits in base X X > 0 Proof of the Uniqueness Let the integer Z has two representations Z = a n-1 X n-1 + a n-2 X n-2 +... + a 1 X + a 0 and Z = b m-1 X m-1 + b m-2 X m-2 +...+ b 1 X + b 0 This implies that a 0 = b 0 (mod X) and thus a 0 = b 0, since all coefficients are < X We continue in similar manner for a 1 and b 1 : a 1 X = b 1 X (mod X 2 ), so a 1 = b 1. And so on. This olso proofs that m = n.

n has length n in unary, but has length $ log 2 n % + 1 in binary Unary is exponentially longer than binary Other Representations: Egyptian Base 3 Conventional Base 3: Each digit can be 0, 1, or 2 Here is a strange new one: Egyptian Base 3 uses -1, 0, 1 Example: (1-1 -1) EB3 = 9-3 - 1 = 5 We can prove a unique representation theorem We can prove a unique representation theorem How could this be Egyptian? Historically, negative numbers first appear in the writings of the Hindu mathematician Brahmagupta (628 AD)

Unary and Binary Triangular Numbers Dot proofs (1+x+x 2 + + x n-1 ) = (x n -1)/(x-1) One weight for each power of 3 Left = negative. Right = positive Study Bee Base-X representations unique binary representations proof for no-leading zero binary k uses $ log 2 k % + 1 = "log 2 (k+1) # digits in base 2 Largest length n number in base X Example Two Case Studies Bases and Representation Solving Recurrences using a good representation T(1) = 1 T(n) = 4T(n/2) + n Notice that T(n) is inductively defined only for positive powers of 2, and undefined on other values T(1) = 1 T(2) = 6 T(4) = 28 T(8) = 120 Give a closed-form formula for T(n)

Technique 1 Guess Answer, Verify by Induction T(1) = 1, T(n) = 4 T(n/2) + n Base Case: G(1) = 1 and T(1) = 1 Induction Hypothesis: T(x) = G(x) for x < n Hence: T(n/2) = G(n/2) = 2(n/2) 2 n/2 T(n) = 4 T(n/2) + n = 4 G(n/2) + n = 4 [2(n/2) 2 n/2] + n = 2n 2 2n + n = 2n 2 n = G(n) Guess: G(n) = 2n 2 - n Technique 2 Guess Form, Calculate Coefficients T(1) = 1, T(n) = 4 T(n/2) + Guess: T(n) = an 2 + bn n + c for some a,b,c Calculate: T(1) = 1, so a + b + c = 1 T(n) = 4 T(n/2) + n an 2 + bn + c = 4 [a(n/2) 2 + b(n/2) + c] + n = an 2 + 2bn + 4c + n (b+1)n + 3c = 0 Therefore: b = -1 c = 0 a = 2 Technique 3 The Recursion Tree Approach T(1) = 1, T(n) = 4 T(n/2) + n A slight variation T(1) = 1, T(n) = 4 T(n/2) + n 2