测试灌水版 #481442 层

求助

楼主 · 1 楼
f[x_] := Sqrt[2*Pi] Exp[-x^2/2]
Plot[f[x], {x, -3, 3}, PlotStyle -> {RGBColor[1, 0, 0], Thickness[0.01]}]
xd = Range[-3.0, 3.0, 0.5];
yd = Map[f, xd];
n = Length[xd];
dat = Table[{xd[[i]], yd[[i]]}, {i, n}]
Do[Do[yd[[j]] = (yd[[j]] - yd[[j - 1]])/(xd[[j]] - xd[[j - 1]]), {j, n,
i + 1, -1}], {i, n - 1}]
Print["Divided Difference =", yd];
pt = yd[[n]];
Do[pt = pt*(x - xd[[i]]) + yd[[i]], {i, n - 1, 1, -1}];
p[x_] := pt;
本人水平有限,找不出问题,但结果太坏!!
2 楼
{j, n, i + 1, -1}], {i, n - 1}
这是什么意思呢?你看以把每句的意思解释一下吧,层层分析一下。不知道这里的pt有什么用,建议在此处修改。