def dup_invert(f, g, K):
 (s, h) = dup_half_gcdex(f, g, K)
 if (h == [K.one]):
  return dup_rem(s, g, K)
 else:
  raise NotInvertible('zero divisor')

def dup_invert ( f , g , K ) : ( s , h ) = dup_half_gcdex ( f , g , K ) if ( h == [ K . one ] ) : return dup_rem ( s , g , K ) else : raise NotInvertible ( 'zero divisor' )
compute multiplicative inverse of f modulo g in f[x] .