Python Method for Calculating diagonal rational function interpolation
This article mainly introduces python's method for calculating diagonal rational function interpolation, which involves Python's mathematical operations. If you need it, refer
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
'''P = rational (xData, yData, x) Evaluates the diagonal rational function interpolant p (x) That passes through he data points ''' From numpy import zeros Def rational (xData, yData, x ): M = len (xData) R = yData. copy () ROld = zeros (m) For k in range (m-1 ): For I in range (m-k-1 ): If abs (x-xData [I + k + 1]) <1.0e-9: Return yData [I + k + 1] Else: C1 = r [I + 1]-r [I] C2 = r [I + 1]-rOld [I + 1] C3 = (x-xData [I])/(x-xData [I + k + 1]) R [I] = r [I + 1] + c1/(c3 * (1.0-c1/c2)-1.0) ROld [I + 1] = r [I + 1] Return r [0] |
I hope this article will help you with Python programming.