Python computing Newton Iteration polynomial instance analysis, python instance analysis
This article describes how to calculate the Newton Iteration polynomial using python. Share it with you for your reference. The specific implementation method is as follows:
'''P = evalPoly (a, xData, x ). evaluates Newton's polynomial p at x. the coefficient vector 'A' can be computed by the function 'coeffts '. a = coeffts (xData, yData ). computes the coefficients of Newton's polynomial. '''def evalPoly (a, xData, x): n = len (xData)-1 # Degree of polynomial p = a [n] for k in range (1, n + 1): p = a [n-k] + (x-xData [n-k]) * p return pdef coeffts (xData, yData ): m = len (xData) # Number of data points a = yData. copy () for k in range (1, m): a [k: m] = (a [k: m]-a [k-1])/(xData [k: m]-xData [k-1]) return
I hope this article will help you with Python programming.