| Author |
Comment/Response |
Peter Pein
|
10/23/09 10:23am
almost straightforward:
In[1]:= data = {{1, 5}, {2, 24}, {3, 63},
{4, 140}, {5, 265}, {6, 450}};
In[2]:= poly = Sum[data[[i,2]]*Product[
Piecewise[{{(x - data[[j,1]])/
(data[[i,1]] - data[[j,1]]),
i != j}}, 1], {j, Length[data]}],
{i, Length[data]}]
Out[6]= (1/24)*(2 - x)*(3 - x)*(4 - x)*(5 - x)*
(6 - x) + (3 - x)*(4 - x)*(5 - x)*
(6 - x)*(-1 + x) + (21/4)*(4 - x)*
(5 - x)*(6 - x)*(-2 + x)*(-1 + x) +
(35/3)*(5 - x)*(6 - x)*(-3 + x)*
(-2 + x)*(-1 + x) + (265/24)*(6 - x)*
(-4 + x)*(-3 + x)*(-2 + x)*(-1 + x) +
(15/4)*(-5 + x)*(-4 + x)*(-3 + x)*
(-2 + x)*(-1 + x)
Test:
In[3]:= Simplify[poly - InterpolatingPolynomial[
data, x]]
Out[3]= 0
URL: , |
|