Computational Complexity of Euclidean Algorithm for Polynomials

computational complexityeuclidean-algorithm

Let us assume that the two polynomials that we have are degree $n$ polynomials. The naive Euclidean Algorithm for univariate polynomial does $O(n)$ divisions and each division takes $O(n^2)$. So shouldn't the naive Euclidean algorithm run for $O(n^3)$ time? But I see in Wikipedia that the algorithm runs for $O(n^2)$. I am not sure what I am missing.

Best Answer

The main point is that each division actually takes something like $O(n(\deg f-\deg g))$ operations if we are trying to divide $f$ by $g$ and $\deg f>\deg g$.

This is what is happening in the Euclidean algorithm, so if the divisions you are doing along the way are $a_i/a_{i+1}$ for $i=0,\dotsc,m$, then the complexity is of the order of $$n\cdot \left( (\deg a_0-\deg a_1)+(\deg a_1-\deg a_2)+\dotsc + (\deg a_{m}-\deg a_{m+1}) \right)$$ which is a telescoping series that gives you $O(n(\deg a_0-\deg a_{m+1}))=O(n^2)$ in the end.

Related Question