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

Algorithm

Lemma

Let , then

For , find in the following way:

  1. Let . Apply Newton’s Method for Polynomial Logarithms to find .
  2. Let . Apply the Fast Fourier Transform to find and .
  3. Use the results from 1 to find .
  4. Apply the Inverse Fast Fourier Transform to find .
  5. Apply the lemma to find .

This algorithm solves the problem in time and space.

std::vector<std::complex<double>> newton_exp(const std::vector<std::complex<double>> &a, int n) {
	std::vector x = {std::complex(1.)};
	for (int m = 1; m < n; m *= 2) {
		auto y = newton_log(x, 2 * m);
		for (int i = 0; i < std::min(2 * m, int(a.size())); i++) {
			y[i] -= a[i];
		}
 
		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] -= x[i] * y[i];
		}
		ifft(4 * m, x);
		x.resize(2 * m);
	}
	x.resize(n);
 
	return x;
}