Python program to evaluate a polynomial with its derivatives
## module evalPoly ''' p,dp,ddp = evalPoly(a,x). Evaluates the polynomial p = a[0] + a[1]*x + a[2]*x^2 +...+ a[n]*x^n with its derivatives dp = p' and ddp = p" at x. ''' def evalPoly(a,x): n = len(a) - 1 p = a[n] dp = 0.0 + 0.0j ddp = 0.0 + 0.0j for i in range(1,n+1): ddp = ddp*x + 2.0*dp dp = dp*x + p p = p*x + a[n-i] return p,dp,ddp