@public
def cofactors(f, g, *gens, **args):
 options.allowed_flags(args, ['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:
   (h, cff, cfg) = domain.cofactors(a, b)
  except NotImplementedError:
   raise ComputationFailed('cofactors', 2, exc)
  else:
   return (domain.to_sympy(h), domain.to_sympy(cff), domain.to_sympy(cfg))
 (h, cff, cfg) = F.cofactors(G)
 if (not opt.polys):
  return (h.as_expr(), cff.as_expr(), cfg.as_expr())
 else:
  return (h, cff, cfg)

@ public def cofactors ( f , g , * gens , ** args ) : options . allowed_flags ( args , [ '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 : ( h , cff , cfg ) = domain . cofactors ( a , b ) except NotImplementedError : raise ComputationFailed ( 'cofactors' , 2 , exc ) else : return ( domain . to_sympy ( h ) , domain . to_sympy ( cff ) , domain . to_sympy ( cfg ) ) ( h , cff , cfg ) = F . cofactors ( G ) if ( not opt . polys ) : return ( h . as_expr ( ) , cff . as_expr ( ) , cfg . as_expr ( ) ) else : return ( h , cff , cfg )
compute gcd and cofactors of f and g .