Polyval(p,x) to evaluate polynomials
Your p array is in the wrong order. You should start with the coefficient of the highest exponent.
Try with p=[1,0,2,1].
I don't know much about Python and I'm trying to use it to do some simple polynomial interpolation, but there's something I'm not understanding about one of the built-in functions. 
I'm trying to use polyval(p,x) to evaluate a polynomial p at x. 
I made an example polynomial p(x) = 1 + 2x + x^3, I created an array p = [1,2,0,1] to define it and I want to know the values at x = 0,1,2 so I created another array x = [0,1,2]. 
Doing polyval(p,x) gave me an output of [1, 4, 17]. p(0) and p(1) are correct, but p(2) should be 13, not 17. Why is it giving me 17?