(f, p, q, K)
return h
Evaluate functional transformation ``q**n * f(p/q)`` in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> R.dup_transform(x**2 - 2*x + 1, x**2 + 1, x - 1)
    x**4 - 2*x**3 + 5*x**2 - 4*x + 4
Evaluate functional transformation ``q**n * f(p/q)`` in ``K[x]``.
Evaluate functional transformation q ** n * f ( p / q ) in K [ x ] .
def dup_transform(f, p, q, K):
    """
    Evaluate functional transformation ``q**n * f(p/q)`` in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> R.dup_transform(x**2 - 2*x + 1, x**2 + 1, x - 1)
    x**4 - 2*x**3 + 5*x**2 - 4*x + 4

    """
    if not f:
        return []

    n = len(f) - 1
    h, Q = [f[0]], [[K.one]]

    for i in xrange(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 xrange ( 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