How to Multiply integers matrices and polynomials Slides
- Slides: 18
How to Multiply integers, matrices, and polynomials Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 1
Complex Multiplication Complex multiplication. (a + bi) (c + di) = x + yi. Grade-school. x = ac - bd, y = bc + ad. 4 multiplications, 2 additions Q. Is it possible to do with fewer multiplications? 2
Complex Multiplication Complex multiplication. (a + bi) (c + di) = x + yi. Grade-school. x = ac - bd, y = bc + ad. 4 multiplications, 2 additions Q. Is it possible to do with fewer multiplications? A. Yes. [Gauss] x = ac - bd, y = (a + b) (c + d) - ac - bd. 3 multiplications, 5 additions Remark. Improvement if no hardware multiply. 3
5. 5 Integer Multiplication
Integer Addition. Given two n-bit integers a and b, compute a + b. Grade-school. (n) bit operations. 1 1 1 0 1 0 1 + 0 1 1 1 0 1 0 1 0 Remark. Grade-school addition algorithm is optimal. 5
Integer Multiplication. Given two n-bit integers a and b, compute a b. Grade-school. (n 2) bit operations. 1 1 0 1 0 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 1 0 1 1 0 1 0 0 0 0 0 0 1 Q. Is grade-school multiplication algorithm optimal? 6
Divide-and-Conquer Multiplication: Warmup To multiply two n-bit integers a and b: Multiply four ½n-bit integers, recursively. Add and shift to obtain result. n n Ex. a = 10001101 b = 11100001 a 1 b 1 a 0 b 0 7
Recursion Tree n T(n) T(n/2) T(n/4) T(n/2) . . . 4(n/2) T(n/4) T(n/4) 16(n/4). . . 4 k (n / 2 k) T(n / 2 k) . . . T(2) 4 lg n (1) 8
Karatsuba Multiplication To multiply two n-bit integers a and b: Add two ½n bit integers. Multiply three ½n-bit integers, recursively. Add, subtract, and shift to obtain result. n n n 1 2 1 3 3 9
Karatsuba Multiplication To multiply two n-bit integers a and b: Add two ½n bit integers. Multiply three ½n-bit integers, recursively. Add, subtract, and shift to obtain result. n n n 1 2 1 3 3 Theorem. [Karatsuba-Ofman 1962] Can multiply two n-bit integers in O(n 1. 585) bit operations. 10
Karatsuba: Recursion Tree n T(n) T(n/2) T(n/4) T(n/4) 3(n/2) T(n/4) T(n/4) 9(n/4). . . 3 k (n / 2 k) T(n / 2 k) . . . T(2) 3 lg n (1) 11
Matrix Multiplication
Dot Product Dot product. Given two length n vectors a and b, compute c = a b. Grade-school. (n) arithmetic operations. Remark. Grade-school dot product algorithm is optimal. 13
Matrix Multiplication Matrix multiplication. Given two n-by-n matrices A and B, compute C = AB. Grade-school. (n 3) arithmetic operations. Q. Is grade-school matrix multiplication algorithm optimal? 14
Block Matrix Multiplication C 11 A 12 B 11 15
Matrix Multiplication: Warmup To multiply two n-by-n matrices A and B: Divide: partition A and B into ½n-by-½n blocks. Conquer: multiply 8 pairs of ½n-by-½n matrices, recursively. Combine: add appropriate products using 4 matrix additions. n n n 16
Fast Matrix Multiplication Key idea. multiply 2 -by-2 blocks with only 7 multiplications. n n 7 multiplications. 18 = 8 + 10 additions and subtractions. 17
Fast Matrix Multiplication To multiply two n-by-n matrices A and B: [Strassen 1969] Divide: partition A and B into ½n-by-½n blocks. Compute: 14 ½n-by-½n matrices via 10 matrix additions. Conquer: multiply 7 pairs of ½n-by-½n matrices, recursively. Combine: 7 products into 4 terms using 8 matrix additions. n n Analysis. Assume n is a power of 2. T(n) = # arithmetic operations. n n 18
- Adding subtracting multiplying dividing integers
- Upper triangular matrix 3x4
- Lesson 4 multiply integers page 237 answers
- How do you add subtract and multiply polynomials
- Monomials
- 6-5 multiplying polynomials answer key
- Multiplying monomials with exponents
- Multiplying polynomials jeopardy
- Matlab polynomial multiplication
- What operations are polynomials closed under
- A small child slides down the four frictionless slides
- Force and work relationship quick check
- Multiply and divide by powers of 10
- Simplify complex numbers
- Add and subtract functions
- One step division equations
- Adding subtracting multiplying dividing decimals
- Multiplying fractions with decimals
- How do we add subtract and multiply complex numbers