找到 f i ( x ) n − 1 {\displaystyle f_{i}(x)n-1} 次多项式,其中: f i ( x i ) = 1 {\displaystyle f_{i}(x_{i})=1} 并且 f i ( x j ) = 0 {\displaystyle f_{i}(x_{j})=0}
注意: f i ( x ) = x n − 1 + . . . {\displaystyle f_{i}(x)=x^{n-1}+...}
与 f i ( x ) = ∏ j = 1 n x j + . . . {\displaystyle f_{i}(x)=\prod _{j=1}^{n}x_{j}+...} 相同
那么
f i ( x ) = ∏ j = 1 n ( x − x j ) ( x i − x j ) {\displaystyle f_{i}(x)=\prod _{j=1}^{n}{\frac {(x-x_{j})}{(x_{i}-x_{j})}}} 其中 j ! = i {\displaystyle j!=i}
现在找到一个 f {\displaystyle f} 次多项式函数,使得 f ( x i ) = a i {\displaystyle f(x_{i})=a_{i}}
f ( x ) = ∑ i = 1 n a i f i ( x ) {\displaystyle f(x)=\sum _{i=1}^{n}a_{i}f_{i}(x)} 其中 j ! = i {\displaystyle j!=i}
所以: f ( x ) = ∑ i = 1 n a i ∏ j = 1 n ( x − x j ) ( x i − x j ) {\displaystyle f(x)=\sum _{i=1}^{n}a_{i}\prod _{j=1}^{n}{\frac {(x-x_{j})}{(x_{i}-x_{j})}}} 其中 j ! = i {\displaystyle j!=i}
(请注意,除非 x = x_i,否则此公式的结果始终为 0)