def dmp_eval(f, a, u, K):
 if (not u):
  return dup_eval(f, a, K)
 if (not a):
  return dmp_TC(f, K)
 (result, v) = (dmp_LC(f, K), (u - 1))
 for coeff in f[1:]:
  result = dmp_mul_ground(result, a, v, K)
  result = dmp_add(result, coeff, v, K)
 return result

def dmp_eval ( f , a , u , K ) : if ( not u ) : return dup_eval ( f , a , K ) if ( not a ) : return dmp_TC ( f , K ) ( result , v ) = ( dmp_LC ( f , K ) , ( u - 1 ) ) for coeff in f [ 1 : ] : result = dmp_mul_ground ( result , a , v , K ) result = dmp_add ( result , coeff , v , K ) return result
evaluate a polynomial at x_0 = a in k[x] using the horner scheme .