Article From:https://www.cnblogs.com/brightyuxl/p/9065052.html

Neville interpolation method

Newton’s interpolation involves two steps: calculating coefficients, then evaluating polynomials. If interpolation works well, use the same polynomial to repeat it at different values of X. If interpolation is a bit, a one-step calculation method of interpolation, such as Neville algorithm, is a more convenient choice.

4 data points

k=0 k=1 k=2 k=3

x0

P0[x0]=y0

P1[x0,x1]

P2[x0,x1,x2]

P3[x0,x1,x2,x3]

x1

P0[x1]=y1

P1[x1,x2]

P2[x1,x2,x3]

x2

P0[x2]=y2

P1[x2,x3]

x3

P0[x3]=y3

Pk[xi,xi+1,,xi+k]=(xxi+k)Pk1[xi,xi+1,,xi+k1]+(xix)Pk1[xi+1,,xi+k]xixi+k

4 data points”

k=0 k=1 k=2 k=3

x0

P0[x0]=y0

P1[x0,x1]=(xx1)P0[x0]+(x0x)P0[x1]x0x1

P2[x0,x1,x2]=(xx2)P1[x0,x1]+(x0x)P1[x1,x2]x0x2

P3[x0,x1,x2,x3]=(xx3)P2[x0,x1,x2]+(x0x)P2[x1,x2,x3]x0x3

x1

P0[x1]=y1

P1[x1,x2]=(xx2)P0[x1]+(x1x)P0[x2]x1x2

P2[x1,x2,x3]=(xx3)P1[x1,x2]+(x1x)P1[x2,x3]x1x3

x2

P0[x2]=y2

P1[x2,x3]=(xx3)P0[x2]+(x2x)P0[x3]x2x3

x3

P0[x3]=y3

Neville algorithm Python code”

import numpy as np
def neville(xData,yData,x):
    m = len(xData)
    A = np.zeros((m,m))  # ARepresentative calculation formA[:, 0]=np.array (np.array (yData))For K in range (1, m):For I in range (m-k):A[i, k]= ((x-xData[i+1]) *A[i, k-1]+ (xData[i]-x) *A[i+1, k-1]) / (xData[i]-xData[i+1])ReTurn A

case analysis

yData = [4.0, 3.9, 3.8, 3.7] 
xData = [-0.06604, -0.02724, 0.01282, 0.05383]
neville(xData,yData,0)

Calculation results

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *