(f, g, *gens, **args)
Half extended Euclidean algorithm of ``f`` and ``g``.

    Returns ``(s, h)`` such that ``h = gcd(f, g)`` and ``s*f = h (mod g)``.

    Examples
    ========

    >>> from sympy import half_gcdex
    >>> from sympy.abc import x

    >>> half_gcdex(x**4 - 2*x**3 - 6*x**2 + 12*x + 15, x**3 + x**2 - 4*x - 4)
    (-x/5 + 3/5, x + 1)
Half extended Euclidean algorithm of ``f`` and ``g``.
Half extended Euclidean algorithm of f and g .
def half_gcdex(f, g, *gens, **args):
    """
    Half extended Euclidean algorithm of ``f`` and ``g``.

    Returns ``(s, h)`` such that ``h = gcd(f, g)`` and ``s*f = h (mod g)``.

    Examples
    ========

    >>> from sympy import half_gcdex
    >>> from sympy.abc import x

    >>> half_gcdex(x**4 - 2*x**3 - 6*x**2 + 12*x + 15, x**3 + x**2 - 4*x - 4)
    (-x/5 + 3/5, x + 1)

    """
    options.allowed_flags(args, ['auto', 'polys'])

    try:
        (F, G), opt = parallel_poly_from_expr((f, g), *gens, **args)
    except PolificationFailed as exc:
        domain, (a, b) = construct_domain(exc.exprs)

        try:
            s, h = domain.half_gcdex(a, b)
        except NotImplementedError:
            raise ComputationFailed('half_gcdex', 2, exc)
        else:
            return domain.to_sympy(s), domain.to_sympy(h)

    s, h = F.half_gcdex(G, auto=opt.auto)

    if not opt.polys:
        return s.as_expr(), h.as_expr()
    else:
        return s, h
def half_gcdex ( f , g , * gens , * * args ) : options . allowed_flags ( args , [ 'auto' , 'polys' ] ) try : ( F , G ) , opt = parallel_poly_from_expr ( ( f , g ) , * gens , * * args ) except PolificationFailed as exc : domain , ( a , b ) = construct_domain ( exc . exprs ) try : s , h = domain . half_gcdex ( a , b ) except NotImplementedError : raise ComputationFailed ( 'half_gcdex' , 2 , exc ) else : return domain . to_sympy ( s ) , domain . to_sympy ( h ) s , h = F . half_gcdex ( G , auto = opt . auto ) if not opt . polys : return s . as_expr ( ) , h . as_expr ( ) else : return s , h