# Lecture 6: Fast Powering and Binary Divide and Conquer Recurrences

### Background Material

• Review divide and conquer recurrence (including Karatsuba) in Lecture 5
• Floor and ceiling functions
• Binary representation of numbers and bit length

• D. Knuth, The Art of Computer Programming Seminumerical Algorithms, Vol. 2, 3rd Ed., Sec. 4.5, Addison-Wesley, 1998.

### Topics

1. Karatsuba's recurrence when sizes of the recursive calls differ
2. Number of bits in the binary representation of a number
3. Binary powering
4. Analysis of binary powering
1. Recurrence relation: M(e) = number of multiplications to compute a^e. M(e) = 1 + M(floor(e/2)) even e, M(e) = 2 + M(floor(e/2)) odd e, M(0) = M(1) = 0.
2. Solution: M(e) = floor(lg(e)) + nu(e) -1, where nu(e) = number of 1 bits in the binary representation of e.

1. none.

### Maple worksheets and programs

• power.mw - Worksheet containing an implementation and analysis of Binary Powering.
Created: Oct. 26, 2006 by jjohnson@cs.drexel.edu