|
"Interpolation Solutions" |
|
Barycentric Method |
|
Array X = {
,
,
,
,
}
Array Y = {
,
,
,
,
}
Specify New X values = {
,
,
,
}
[ Initial ArrayValues X: {0,2,4,6,8} ]
[ Initial ArrayValues Y: {0,4,16,36,64} ]
[ Initial BarycentricX Values specified: {1,3,5,7} ]
|
IMPLEMENTATION
Barycentric Interpolation
The Lagrange interpolation method (see) Lagrange Interpolation
requires recomputation for all of the terms for each distinct x value, meaning that this method
can be applied for small numbers n of nodes. Some shortcomings are associated with the Lagrange
interpolation:
- Each evaluation of f(x) requires O(n2) additions and multiplications.
- Adding a new data point (xn+1,yn+1) requires a new computation from scratch.
- The computation is numerically unstable.
In order to improve the Lagrange method, simply rearrange the terms in the equation of the Lagrange interpolation by
defining weight functions that do not depend on the interpolated value of x.
Algorithm Creation
Introduce the quantity
l(x) = (x - x0)(x - x1)... (x - xn)
|
Then rearrange the Lagrange basis polynomial as
li(x) = [l(x) / x - xi] * [1 /
∏nj=0,j≠i (xi - xj)]
|
Define the barycentric weight functions
wi = 1 / ∏j=0,j≠i(xi - xj)
|
Then simply write
which is usually referred to as the barycentric interpolation formula. The advantage of this representation is that the
interpolation polynomial may now be evaluated as
y = f(x) = l(x) ∑i wi / x - xi f(xi)
|
Testing the Barycentric Method
In order to test the Barycentric method as defined above, a new TestBarycentric()
static method has been added and executed. Supporting code and methods are not shown.
static void TestBarycentric();
{
ListBox1.Items.Clear();
ListBox2.Items.Clear();
double[] xarray = new double[] { t1, t2, t3, t4, t5 };
double[] yarray = new double[] { t6, t7, t8, t9, t10 };
double[] x = new double[] { t11, t12, t13, t14 };
double[] y = Interpolation.Barycentric(xarray, yarray, x);
VectorR vx = new VectorR(x);
VectorR vy = new VectorR(y);
ListBox1.Items.Add(" " + vx.ToString());
ListBox2.Items.Add(" " + vy.ToString());
}
|
We first defined a set of data points as xarray and yarray (same input as in) Lagrange Interpolation,
which represent a set of given data points. The Barycentric method returns
a single y value or a y array at the input x.
The user can manipulate all values and try variations on the arrays themselves as well as specifying
new xBarycentric values. Running this example generates the results shown above. From the data points described by x array
and y array, we see that the given data can be expressed in term of an analytic function y = x2.
The Barycentric method gives the exact results expected from the analytic function.
|
|
|