Newton’s Method for Polynomial Inversion is an algorithm that computes for a formal power series such that in time and space.

Tip

This problem can also be solved by Newton’s Method for Polynomial Powers in time and space.

Algorithm

Lemma

Let , then

For , find in the following way:

  1. Let . Apply the Fast Fourier Transform to find and .
  2. Use the results from 0 to find .
  3. Apply the Inverse Fast Fourier Transform to find .
  4. Apply the lemma to find .

This algorithm solves the problem in time and space.

std::vector<std::complex<double>> newton_inv(const std::vector<std::complex<double>> &a, int n) {
	std::vector x = {1. / a[0]};
	for (int m = 1; m < n; m *= 2) {
		std::vector y(a.begin(), a.begin() + std::min(2 * m, int(a.size())));
		x.resize(4 * m, 0), y.resize(4 * m, 0);
		fft(4 * m, x), fft(4 * m, y);
		for (int i = 0; i < 4 * m; i++) {
			x[i] *= 1. * 2 - x[i] * y[i];
		}
		ifft(4 * m, x);
		x.resize(2 * m);
	}
	x.resize(n);
 
	return x;
}