pub fn xgcd(&self, y: &Self) -> (Self, Self, Self) {
        let one = Polynomial::new(&[FieldElement::one()]);
        let zero = Polynomial::zero();
        let (mut old_r, mut r) = (self.clone(), y.clone());
        let (mut old_s, mut s) = (one.clone(), zero.clone());
        let (mut old_t, mut t) = (zero.clone(), one.clone());

        while r != Polynomial::zero() {
            let quotient = old_r.clone().div_with_ref(&r);
            old_r = old_r - &quotient * &r;
            core::mem::swap(&mut old_r, &mut r);
            old_s = old_s - &quotient * &s;
            core::mem::swap(&mut old_s, &mut s);
            old_t = old_t - &quotient * &t;
            core::mem::swap(&mut old_t, &mut t);
        }

        let lcinv = old_r.leading_coefficient().inv().unwrap();
        (
            old_s.scale_coeffs(&lcinv),
            old_t.scale_coeffs(&lcinv),
            old_r.scale_coeffs(&lcinv),
        )
    }
Extended Euclidean Algorithm for polynomials.

This method computes the extended greatest common divisor (GCD) of two polynomials `self` and `y`.
It returns a tuple of three elements: `(a, b, g)` such that `a * self + b * y = g`, where `g` is the
greatest common divisor of `self` and `y`.
crates/math/src/polynomial/mod.rs