11 February 2014

Fork me on GitHub

(Missing first 17 min of lecture.)

  • Integer multiplication
  • Polynomial multiplication
    • FFT
    • Numerical precision issues
  • Variable divide-and-conquer

Polynomial multiplication

\[\ x(z) = x_0 + x_1 z + x_2 x^2 + \cdots + x_{n - 1} z ^ {n - 1} \] and similarly for \( y(z) \). What is \( x(z) y(z) \)?

Evaluate x and y at N = 2 ^ k \geq 2n - 1 points z. Pointwise multiply x(z) and y(z) to get p(z) = x(z) y(z) at N points. Interpolate values to get coefficients of p.

Now it look like he's talking about complex roots of unity: \[ \omega_{l, N} = e ^ {l i (2 \pi / N) } \] Consider \( l \in {0, ..., N - 1} \). Because roots of unity wrap around, if you square all these roots of unity, you end up with \( N / 2 \) distinct values, not \( N \).

Consider \[ a = a_0 + a_1 z + a_ z + \cdots + a_{n - 1 } z ^ {n - 1}. \] Consider two polynomials of half the degree, and either the even or odd coefficients: \[ a_{even} = a_0 + a_2 z + a_4 z^2 + \cdots + a_{n - 2} z ^ {(n-2)/2} \] \[ a_{odd} = a_1 + a_3 z + a_5 z^2 + \cdots + a_{n - 1} z ^ {(n-2)/2} \]

Note \[ a = a_{even}(z ^ 2) + a_{odd}(z^2) z \]

Evaluate (a, N = 2 ^ k):
a_even <- even coefficients
a_odd <- odd coefficients
eval(a_even, N / 2)
eval(a_odd, N / 2)
For l = 0 to N - 1:
  a(omega(l, n)) <- a_even(omega(l mod N / 2, N /  2)) + a_odd(omega(l mod N / 2, N / 2)) * omega(l, N)

The recurrence relation is the above is \( T(n) = 2 T(N/2) + O(N) \). So \( T(n) \in O(n \log n) \).

Now we've done efficient pointwise multiplication, but we still need to interpolate to get coefficent values of p. Note we can get the first coefficient by looking at the case where \( l = 0 \). Write \[ a(z) = a_{even}(z^2) + z a_{odd}(z^2) \] Look at \( \omega_{l, N}, \omega_{l + N / 2, N} \). Note their squares are equal. So \[ a(omega(l, N)) = aeven(omega(l, N / 2)) + omega(l, N) * aodd(omega(l, N/2)) \\ \] \[ a(omega(l + N / 2, N)) = aeven(omega(l, N / 2)) - omega(l, N) * aodd(omega(l, N/2)) \\ \] This allows you to get expressions for aeven and aodd. You can use these to recursively find the coefficients of aeven and aodd using another divide-and-conquer scheme. Once you have the coefficients of aeven and aodd, you can read off the coefficients for a.

A linear algebra interpretation

You can also think of the above as a matrix inversion problem (drawn on board, not copied here).

Are we done?

We reduce integer multiplication to polynomial multiplication, and we can do the latter in \( O(n \log n) \). So can we do the first in \( O (n \log n) \)? We need to make sure we have sufficiently high precision. Note we're using integer multiplication to do operations on complex numbers.

Say to represent complex numbers we used \(B\) bits. Our initial error will be around \( 2 ^ {-B} \). Each number is involved in \( O (\log n) \) operations. (The rest of this was rather rushed, maybe someone else has better notes.)