def dmp_compose(f, g, u, K):
 if (not u):
  return dup_compose(f, g, K)
 if dmp_zero_p(f, u):
  return f
 h = [f[0]]
 for c in f[1:]:
  h = dmp_mul(h, g, u, K)
  h = dmp_add_term(h, c, 0, u, K)
 return h

def dmp_compose ( f , g , u , K ) : if ( not u ) : return dup_compose ( f , g , K ) if dmp_zero_p ( f , u ) : return f h = [ f [ 0 ] ] for c in f [ 1 : ] : h = dmp_mul ( h , g , u , K ) h = dmp_add_term ( h , c , 0 , u , K ) return h
evaluate functional composition f(g) in k[x] .