#NEWLINE# def dup_scale( f , a , K ) : #NEWLINE# #INDENT# '\n    Evaluate efficiently composition ``f(a*x)`` in ``K[x]``.\n\n    Examples\n    ========\n\n    >>> from sympy.polys import ring, ZZ\n    >>> R, x = ring("x", ZZ)\n\n    >>> R.dup_scale(x**2 - 2*x + 1, ZZ(2))\n    4*x**2 - 4*x + 1\n\n    ' #NEWLINE# ( f , n , b ) = ( list ( f ) , ( len ( f ) - 1 ) , a ) #NEWLINE# for i in range ( ( n - 1 ) , ( - 1 ) , ( - 1 ) ) : #NEWLINE# #INDENT# ( f [ i ] , b ) = ( ( b * f [ i ] ) , ( b * a ) ) #NEWLINE# #UNINDENT# return i