Live data from Hacker News

How to multiply polynomials in Θ(n log n) time

agarri.ga

11–20 of 30 posts

Re: How to multiply polynomials in Θ(n log n) time

#11
Can anybody guess in which way he used convolution for solving what is generally known as the change-making problem? Wikipedia [1] mentions a "probabilistic convolution tree", but that seems much more involved.

Edit: Solved. I've missed that the problem only deals with change amounts that can be reached with one or two coins. So a single convolution is sufficient in this specific case.

https://en.wikipedia.org/wiki/Change-making_problem

Re: How to multiply polynomials in Θ(n log n) time

#12
post #10

Fun article, but it was missing a little bit that took me a minute to get. So if you're already familiar with fourier transforms, this might be the missing piece to this article: Multiplication of polynomials when expressed in the domain of "array of coefficients" is a convolution operation: really you're summing (AB)_k = sum_{i=0}^k A_i B_{k-i} to find the kth coefficient of the result. The indices for B go backward…

[deleted]

Re: How to multiply polynomials in Θ(n log n) time

#13
post #6

This is technically not an O(n lg n) algorithm. Any O(n lg n) polynomial multiplication algorithm can be trivially turned into an O(n lg n) multiplication algorithm (just throw in some carries at the end), but O(n lg n) multiplication is an open problem. In this case the issue is that you need more and more precision for the FFT as the inputs get larger, or else you'll get the wrong answer. I think it ends up being a…

IIRC if your polynomials have integer coefficients with a bounded number of digits you can use FFT on finite rings and get an actual O(n log n) algorithm.

Re: How to multiply polynomials in Θ(n log n) time

#14
post #13
post #6

This is technically not an O(n lg n) algorithm. Any O(n lg n) polynomial multiplication algorithm can be trivially turned into an O(n lg n) multiplication algorithm (just throw in some carries at the end), but O(n lg n) multiplication is an open problem. In this case the issue is that you need more and more precision for the FFT as the inputs get larger, or else you'll get the wrong answer. I think it ends up being a…

IIRC if your polynomials have integer coefficients with a bounded number of digits you can use FFT on finite rings and get an actual O(n log n) algorithm.

This is not quite correct. A finite ring can only have finitely many primitive roots of unity, so the length of the FFTs you can compute in a ring of fixed size is bounded. To compute arbitrarily long convolutions over a finite ring, you need to extend the ring with more roots of unity (for example, using the Schönhage-Strassen trick), and this increases the complexity.

Re: How to multiply polynomials in Θ(n log n) time

#15

This blog post is doing precise integer arithmetic without rounding, and dealing with polynomials of tiny degree. But for more general uses... Anyone trying to work with polynomials as continuous functions using floating point arithmetic (or trying to work efficiently with piecewise continuous functions in general) should check out Chebfun, http://www.chebfun.org People should avoid working with polynomials expressed…

[deleted]

Re: How to multiply polynomials in Θ(n log n) time

#16

This blog post is doing precise integer arithmetic without rounding, and dealing with polynomials of tiny degree. But for more general uses... Anyone trying to work with polynomials as continuous functions using floating point arithmetic (or trying to work efficiently with piecewise continuous functions in general) should check out Chebfun, http://www.chebfun.org People should avoid working with polynomials expressed…

[deleted]

Re: How to multiply polynomials in Θ(n log n) time

#17
post #13
post #6

This is technically not an O(n lg n) algorithm. Any O(n lg n) polynomial multiplication algorithm can be trivially turned into an O(n lg n) multiplication algorithm (just throw in some carries at the end), but O(n lg n) multiplication is an open problem. In this case the issue is that you need more and more precision for the FFT as the inputs get larger, or else you'll get the wrong answer. I think it ends up being a…

IIRC if your polynomials have integer coefficients with a bounded number of digits you can use FFT on finite rings and get an actual O(n log n) algorithm.

The number of digits needed to hold an output coefficient (and intermediate coefficients during the transform) increases with the number of input coefficients (because so many get added together). This forces the size of the ring to increase to accommodate the larger values, and pushes the runtime past O(n lg n).

Re: How to multiply polynomials in Θ(n log n) time

#18
post #7

[deleted]

This is completely wrong. Big-theta does mean it's an upper bound, and also a lower bound. It certainly does not mean it's the exact number of steps; for example, 5x = Θ(3x), but 5x is more than 3x for all positive x.

Since the parent removed their comment, the gist was that they described f being big-theta of g as f growing exactly as fast as g. this is stricter than what big-theta actually means and is actually defined as "on the order of" or in notation as f ~ g.

Re: How to multiply polynomials in Θ(n log n) time

#19
post #6

This is technically not an O(n lg n) algorithm. Any O(n lg n) polynomial multiplication algorithm can be trivially turned into an O(n lg n) multiplication algorithm (just throw in some carries at the end), but O(n lg n) multiplication is an open problem. In this case the issue is that you need more and more precision for the FFT as the inputs get larger, or else you'll get the wrong answer. I think it ends up being a…

Chapter 1 [1] of Chee Yap's "Fundamental Problems of Algorithmic Algebra" [2] gives integer multiplication at O(n lg(n) lg(lg(n))). To prove that bound a "discrete Fourier transform" is used using modular arithmetic over 2^L + 1 (for suitable L).

As you say, you can always convert to an integer multiplication problem so it stands at O(n lg(n) lg(lg(n))) (not O(n lg^2(n))).

[1] http://cs.nyu.edu/~yap/book/alge/ftpSite/l1.ps.gz

[2] https://www.cs.nyu.edu/yap/book/berlin/

Re: How to multiply polynomials in Θ(n log n) time

#20

Can anybody guess in which way he used convolution for solving what is generally known as the change-making problem? Wikipedia [1] mentions a "probabilistic convolution tree", but that seems much more involved. Edit: Solved. I've missed that the problem only deals with change amounts that can be reached with one or two coins. So a single convolution is sufficient in this specific case. https://en.wikipedia.org/wiki/C…

probabilistic convolution tree is not much more involved. In some sense it's just multiple polynomial multiplication.

But anyway, coin change problem can be solved much faster. http://link.springer.com/article/10.1007%2Fs00453-007-0162-8

Post reply on HN