def dup_transform(f, p, q, K):
 if (not f):
  return []
 n = (len(f) - 1)
 (h, Q) = ([f[0]], [[K.one]])
 for i in range(0, n):
  Q.append(dup_mul(Q[(-1)], q, K))
 for (c, q) in zip(f[1:], Q[1:]):
  h = dup_mul(h, p, K)
  q = dup_mul_ground(q, c, K)
  h = dup_add(h, q, K)
 return h

def dup_transform ( f , p , q , K ) : if ( not f ) : return [ ] n = ( len ( f ) - 1 ) ( h , Q ) = ( [ f [ 0 ] ] , [ [ K . one ] ] ) for i in range ( 0 , n ) : Q . append ( dup_mul ( Q [ ( - 1 ) ] , q , K ) ) for ( c , q ) in zip ( f [ 1 : ] , Q [ 1 : ] ) : h = dup_mul ( h , p , K ) q = dup_mul_ground ( q , c , K ) h = dup_add ( h , q , K ) return h
evaluate functional transformation q**n * f in k[x] .