WebSafe 3.7fncbook.com
|
|
🏠
Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The barycentric formula

The Lagrange formula (9.1.4) is useful theoretically but not ideal for computation. For each new value of xx, all the cardinal functions β„“k\ell_k must be evaluated at xx, which requires a product of nn terms. Thus, the total work is O(n2)O(n^2) for every value of xx. Moreover, the formula is numerically unstable. An alternative version of the formula improves on both issues.

9.2.1DerivationΒΆ

We again will use the error indicator function Ξ¦\Phi from Definition 9.1.2,

Ξ¦(x)=∏j=0n(xβˆ’tj), \Phi(x) = \prod_{j=0}^n (x-t_j),

as well as a set of values derived from the nodes.

The following formula is the key to efficient and stable evaluation of a polynomial interpolant.

Equation (9.2.3) is certainly an odd-looking way to write a polynomial! Indeed, it is technically undefined when xx equals one of the nodes, but in fact, lim⁑xβ†’tkp(x)=yk\lim_{x\to t_k} p(x) = y_k, so a continuous extension to the nodes is justified. (See ExerciseΒ 9.2.3.)

9.2.2ImplementationΒΆ

For certain important node distributions, simple formulas for the weights wkw_k are known. Otherwise, the first task of an implementation is to compute the weights wkw_k, or more conveniently, wkβˆ’1w_k^{-1}.

We begin with the singleton node set {t0}\{t_0\}, for which one gets the single weight w0=1w_0=1. The idea is to grow this singleton into the set of all nodes through a recursive formula. Define Ο‰k,mβˆ’1\omega_{k,m-1} (for k<mk< m) as the inverse of the weight for node kk using the set {t0,…,tmβˆ’1}\{t_0,\ldots,t_{m-1}\}. Then

Ο‰k,m=∏j=0jβ‰ km(tkβˆ’tj)=Ο‰k,mβˆ’1β‹…(tkβˆ’tm),k=0,1,…,mβˆ’1.\omega_{k,m} = \displaystyle \prod_{\substack{j=0\\j\neq k}}^{m} (t_k - t_j) = \omega_{k,m-1} \cdot (t_k-t_{m}), \qquad k=0,1,\ldots,m-1.

A direct application of (9.2.2) can be used to find Ο‰m,m\omega_{m,m}. This process is iterated over m=1,…,nm=1,\ldots,n to find wk=Ο‰k,nβˆ’1w_k=\omega_{k,n}^{-1}.

In Function 9.2.1 we give an implementation of the barycentric formula for polynomial interpolation.

Computing all n+1n+1 weights in Function 9.2.1 takes O(n2)O(n^2) operations. Fortunately, the weights depend only on the nodes, not the data, and once they are known, computing p(x)p(x) at a particular value of xx takes just O(n)O(n) operations.

9.2.3StabilityΒΆ

You might suspect that as the evaluation point xx approaches a node tkt_k, subtractive cancellation error will creep into the barycentric formula because of the term 1/(xβˆ’tk)1/(x-t_k). While such errors do occur, they turn out not to cause trouble, because the same cancellation happens in the numerator and denominator. In fact, the stability of the barycentric formula has been proved, though we do not give the details.

9.2.4ExercisesΒΆ