'Extended Euclidean algorithm, if univariate.'

def gcdex(f, g):

    (lev, dom, per, F, G) = f.unify(g)
    if (not lev):
        (s, t, h) = dup_gcdex(F, G, dom)
        return (per(s), per(t), per(h))
    else:
        raise ValueError('univariate    polynomial    expected')
