I wrote a Lagrange polynomial interpolation class. It works fine. At the beginning some definitions: $$ \begin{align} &\text{nodes}:\qquad x_0, \dots, x_n \\ &\text{values}:\qquad f(x_0), \dots, f(x_n) \\ &\text{weights}:\qquad w_0, \dots, w_n\qquad\text{where}~~~ w_j = \prod_{k=0, k \neq j}^{n}(x_j-x_k)^{-1} \\ &\text{coeff}:\qquad f(x_0)w_0, \dots, f(x_n)w_n. \end{align} $$$$ \begin{align} &nodes:\qquad x_0, \dots, x_n \\ &values:\qquad f(x_0), \dots, f(x_n) \\ &weights:\qquad w_0, \dots, w_n\qquad\text{where}~~~ w_j = \prod_{k=0, k \neq j}^{n}(x_j-x_k)^{-1} \\ &coeff:\qquad f(x_0)w_0, \dots, f(x_n)w_n. \end{align} $$
ValueLet's denote $$c_i = f(x_i)w_i.$$ Value of approximation at some point is equal to $$ \begin{align} p(x) = l(x) \sum_{i=0}^{n} w_i(x-x_i)^{-1}, \qquad \text{where}~~l(x) = \prod_{i=0}^{n}(x-x_i). \end{align} $$$$ \begin{align} p(x) = l(x) \sum_{i=0}^{n} c_i(x-x_i)^{-1}, \qquad \text{where}~~l(x) = \prod_{i=0}^{n}(x-x_i). \end{align} $$