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

${x}_{0}$

${P}_{0}\left[{x}_{0}\right]={y}_{0}$

${P}_{1}\left[{x}_{0},{x}_{1}\right]$

${P}_{2}\left[{x}_{0},{x}_{1},{x}_{2}\right]$

${P}_{3}\left[{x}_{0},{x}_{1},{x}_{2},{x}_{3}\right]$

${x}_{1}$

${P}_{0}\left[{x}_{1}\right]={y}_{1}$

${P}_{1}\left[{x}_{1},{x}_{2}\right]$

${P}_{2}\left[{x}_{1},{x}_{2},{x}_{3}\right]$

${x}_{2}$

${P}_{0}\left[{x}_{2}\right]={y}_{2}$

${P}_{1}\left[{x}_{2},{x}_{3}\right]$

${x}_{3}$

${P}_{0}\left[{x}_{3}\right]={y}_{3}$

## 4 data points”

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

${x}_{0}$

${P}_{0}\left[{x}_{0}\right]={y}_{0}$

${P}_{1}\left[{x}_{0},{x}_{1}\right]=\frac{\left(x-{x}_{1}\right){P}_{0}\left[{x}_{0}\right]+\left({x}_{0}-x\right){P}_{0}\left[{x}_{1}\right]}{{x}_{0}-{x}_{1}}$

${P}_{2}\left[{x}_{0},{x}_{1},{x}_{2}\right]=\frac{\left(x-{x}_{2}\right){P}_{1}\left[{x}_{0},{x}_{1}\right]+\left({x}_{0}-x\right){P}_{1}\left[{x}_{1},{x}_{2}\right]}{{x}_{0}-{x}_{2}}$

${P}_{3}\left[{x}_{0},{x}_{1},{x}_{2},{x}_{3}\right]=\frac{\left(x-{x}_{3}\right){P}_{2}\left[{x}_{0},{x}_{1},{x}_{2}\right]+\left({x}_{0}-x\right){P}_{2}\left[{x}_{1},{x}_{2},{x}_{3}\right]}{{x}_{0}-{x}_{3}}$

${x}_{1}$

${P}_{0}\left[{x}_{1}\right]={y}_{1}$

${P}_{1}\left[{x}_{1},{x}_{2}\right]=\frac{\left(x-{x}_{2}\right){P}_{0}\left[{x}_{1}\right]+\left({x}_{1}-x\right){P}_{0}\left[{x}_{2}\right]}{{x}_{1}-{x}_{2}}$

${P}_{2}\left[{x}_{1},{x}_{2},{x}_{3}\right]=\frac{\left(x-{x}_{3}\right){P}_{1}\left[{x}_{1},{x}_{2}\right]+\left({x}_{1}-x\right){P}_{1}\left[{x}_{2},{x}_{3}\right]}{{x}_{1}-{x}_{3}}$

${x}_{2}$

${P}_{0}\left[{x}_{2}\right]={y}_{2}$

${P}_{1}\left[{x}_{2},{x}_{3}\right]=\frac{\left(x-{x}_{3}\right){P}_{0}\left[{x}_{2}\right]+\left({x}_{2}-x\right){P}_{0}\left[{x}_{3}\right]}{{x}_{2}-{x}_{3}}$

${x}_{3}$

${P}_{0}\left[{x}_{3}\right]={y}_{3}$

## 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