Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d254de

Browse files
author
Oleksandr Kulkov
authored
clarification on half-GCD algorithm
1 parent 2d1a821 commit 1d254de

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/algebra/polynomial.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,13 @@ T resultant(poly<T> a, poly<T> b) {
355355

356356
### Half-GCD algorithm
357357

358-
There is a way to calculate the GCD and resultants in $O(n \log^2 n)$. To do this you should note that if you consider $a(x) = a_0 + x^k a_1$ and $b(x) = b_0 + x^k b_1$ where $k=\min(\deg a, \deg b)/2$ then basically the first few operations of Euclidean algorithm on $a(x)$ and $b(x)$ are defined by the Euclidean algorithm on $a_1(x)$ and $b_1(x)$ for which you may also calculate GCD recursively and then somehow memorize linear transforms you made with them and apply it to $a(x)$ and $b(x)$ to lower the degrees of polynomials. Implementation of this algorithm seems pretty tedious and technical thus it's not considered in this article yet.
358+
There is a way to calculate the GCD and resultants in $O(n \log^2 n)$.
359+
360+
The procedure to do so implements a $2 \times 2$ linear transform which maps a pair of polynomials $a(x)$, $b(x)$ into another pair $c(x), d(x)$ such that $\deg d(x) \leq \frac{\deg a(x)}{2}$. If you're careful enough, you can compute the half-GCD of any pair of polynomials with at most $2$ recursive calls to the polynomials which are at least $2$ times smaller.
361+
362+
The specific details of the algorithm are somewhat tedious to explain, however you can find its implementation in the library, as `half_gcd` function.
363+
364+
After half-GCD is implemented, you can repeatedly apply it to polynomials until you're reduced to the pair of $\gcd(a, b)$ and $0$.
359365

360366
## Problems
361367

0 commit comments

Comments
 (0)