(f, g, u, K)
return h
Evaluate functional composition ``f(g)`` in ``K[X]``.

    Examples
    ========

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

    >>> R.dmp_compose(x*y + 2*x + y, y)
    y**2 + 3*y
Evaluate functional composition ``f(g)`` in ``K[X]``.
Evaluate functional composition f ( g ) in K [ X ] .
def dmp_compose(f, g, u, K):
    """
    Evaluate functional composition ``f(g)`` in ``K[X]``.

    Examples
    ========

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

    >>> R.dmp_compose(x*y + 2*x + y, y)
    y**2 + 3*y

    """
    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