# 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

### Optional Reading

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

### Topics

- Karatsuba's recurrence when sizes of the recursive calls differ
- Number of bits in the binary representation of a number
- Binary powering
- Analysis of binary powering
- 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.
- Solution: M(e) = floor(lg(e)) + nu(e) -1, where nu(e) = number of 1 bits in the binary representation
of e.

### Slides

- 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