This preview shows pages 1–18. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: COMPSCI 102 Discrete Mathematics for Computer Science Ancient Wisdom: On Raising A Number To A Power Lecture 12 a 1 5 1 5 The Egyptians used decimal numbers but multiplied and divided in binary Egyptian Multiplication a x b By Repeated Doubling b has nbit representation: b n1 b n2 b 1 b Starting with a, repeatedly double largest number so far to obtain: a, 2a, 4a, ., 2 n1 a Sum together all the 2 k a where b k = 1 a b = b 2 a + b 1 2 1 a + b 2 2 2 a + + b n1 2 n1 a 2 k a is in the sum if and only if b k = 1 b = b 2 + b 1 2 1 + b 2 2 2 + + b n1 2 n1 Wait! How did the Egyptians do the part where they converted b to binary? They used repeated halving to do base conversion! Egyptian Base Conversion Output stream will print right to left Input X; repeat { if (X is even) then print 0; else {X := X1; print 1;} X := X/2 ; } until X=0; Sometimes the Egyptians combined the base conversion by halving and multiplication by doubling into a single algorithm Binary for 13 is 1101 = 2 3 + 2 2 + 2 70*13 = 70*2 3 + 70*2 2 + 70*2 70 x 13 Rhind Papyrus [1650 BC] 70 140 280 560 13 6 3 1 * 70 350 910 Doubling Halving Odd? Running Total * * 5 x 30 5 10 20 40 30 15 7 3 * 30 70 Doubling Halving Odd? Running Total * * 80 1 150 * 10 184 / 17 Rhind Papyrus [1650 BC] Doubling Powers of 2 Check 17 34 68 136 1 2 4 8 * * 184 = 17*8 + 17*2 + 14 184/17 = 10 with remainder 14 This method is called Egyptian Multiplication / Division or Russian Peasant Multiplication / Division 1101 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Standard Binary Multiplication = Egyptian Multiplication We can view numbers in many different, but corresponding ways Representation: Representation: Understand the relationship between Understand the relationship between different representations of the same different representations of the same information or idea information or idea 1 2 3 Our story so far Induction is how we define and manipulate mathematical ideas Induction has many guises Master their interrelationship Formal Arguments Loop Invariants Recursion Algorithm Design Recurrences Our story so far Abstraction Abstraction : : Abstract away the inessential Abstract away the inessential features of a problem or solution features of a problem or solution = Lets Articulate a New One: b:=a 8 b:=a*a b:=b*a b:=b*a b:=b*a b:=b*a b:=b*a b:=b*a b:=a*a b:=b*b...
View
Full
Document
This document was uploaded on 01/17/2012.
 Fall '09

Click to edit the document details