© 2001 by CRC Press LLC
Notice that in Input[2], the Mathematica functions Length has been applied
to determine the number of components in the array y, Table is used to initialize a
matrix of n by n with the character x, and MatrixForm allows the matrix, yanddys,
to be printed in a matrix form. Input[3] stores the y array into the first column of
the matrix yanddys by application of the Mathematica command Do. Such looping
is extended in Input[4] where the higher order differences are generated by using
an inner index i and an outer index j. The column number j of the matrix yanddys
is increased from 2 to n but the length of each column is continuously decreased to
n-j + 1. Such DoDo arrangement is made possible by keeping the y values and their
differences in a column-by-column form.
4.3 PROGRAM LAGRANGI — APPLICATIONS OF LAGRANGIAN
INTERPOLATION FORMULA
Program LagrangI is designed to curve-fit a given set of n points, (x
i
,f
i
) for i = 1,
2,…,n, by a polynomial of n-1st degree based on the Lagrangian Interpolation
Formula:
(1)
If only the value of the function f(x) at a specified value of x = x
s
is needed,
then Equation 1 can be applied to compute
(2)
In Equations 1 and 2, the symbol is to represent a product of a specified
number of factors such as:
(3)
Equation 1 can be proven if we write the equation which fits the n given points
(x
i
,f
i
) for i = 1 to n by a combination of n functions L
1 to n
(x) as:
(4)
Notice that the ordinates f
1 to n
are utilized in Equation 4. We expect the functions
L
1 to n
(x) to behave in such a way that when x = x
i
only the f
i
L
i
(x) term in Equation
4 will contribute to f(x). That is to say when x = x
i
, L
i
(x
i
) should be equal to unity
and the other L(x) should be equal to zero. Mathematically, we write demand that:
fx f x x x x
i
i
n
kik
k
ki
n
()
=−
()
−
()
[]
=
=
≠
∑
∏
1
1
fx f x x x x
s
i
i
n
kik
k
ki
n
()
=−
()
−
()
[]
=
=
≠
∑
∏
1
2
1
FFFF
k
k
n
n
=
∏
=…
1
12
fx fL x fL x fL x
nn
()
=
()
+
()
+…+
()
11 2 2