Solution (source code)

= Solution

The <Lagrange interpolation polynomial> is
$$
p(x)=\sum_{r=0}^n u_r\frac{\pi_{n,r}(x)}{\pi_{n,r}(x_r)},\qquad
\boxed{w_r=\frac1{\pi_{n,r}(x_r)}=\frac1{\pi_n'(x_r)}=\prod_{s\ne r}(x_r-x_s)^{-1}.}
$$
The <interpolation nodes> are distinct, so these weights are well defined. Applying the same <Lagrange interpolation> to the constant <polynomial> one gives $1=\sum_r w_r\pi_{n,r}(x)$. Dividing this identity and the formula for $p$ by $\pi_n(x)$ gives the <barycentric interpolation formula>
$$
\boxed{p(x)=\frac{\sum_{r=0}^n w_ru_r/(x-x_r)}{\sum_{r=0}^n w_r/(x-x_r)}.}
$$
This displayed quotient is used away from the <interpolation nodes>; at $x=x_r$ its removable singularity is evaluated by setting $p(x_r)=u_r$. Multiplying every weight by the same nonzero constant leaves the quotient unchanged.

\b[Chebyshev points are generally more reliable at high degree.] The <Chebyshev-Lobatto nodes>, or the affine images of the roots of a <Chebyshev polynomial>, cluster near the interval endpoints and control the amplification measured by the <Lebesgue constant of interpolation>. Equally spaced <interpolation nodes> can produce large endpoint oscillations and the <Runge phenomenon>. This is a comparison of numerical robustness and general approximation behaviour, not a claim that one set minimizes the error for every individual <function>.