def polyval(p, x): """ Evaluate a polynomial at specific values. If p is of length N, this function returns the value: p[0]*x**(N-1) + p[1]*x**(N-2) + ... + p[N-2]*x + p[N-1] If x is a sequence, then p(x) is returned for each element of x. If x is another polynomial then the composite polynomial p(x(t)) is returned. :param p: (*array_like*) 1D array of polynomial coefficients (including coefficients equal to zero) from highest degree to the constant term. :param x: (*array_like*) A number, an array of numbers, or an instance of poly1d, at which to evaluate p. :returns: Polynomial value """ if isinstance(x, list): x = MIArray(ArrayUtil.array(x)) return MIArray(ArrayMath.polyVal(p, x.asarray()))