Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = 5;
- f[t_] := 1/(1 + t);
- Do[x[k] = k/n, {k, 0, n}];
- w[t_] := Product[t - x[k], {k, 0, n}];
- Do[w[k_, t_] := w[t]/(t - x[k]), {k, 0, n}];
- Do[l[k_, t_] := w[k, t]/Simplify[w[k, t] /. t -> x[k]], {k, 0, n}];
- L[f_, t_] := Sum[f[x[k]]*l[k, t], {k, 0, n}];
- m = Expand[L[f, t]]
- Plot[Abs[f[t] - m], {t, 0, 1}, PlotRange -> All]
- n = 5;
- f[t_] := 1/(1 + t);
- Do[x[k] = (Sin[(2*k + 1)*Pi/(4 n + 4)])^2, {k, 0, n}];
- w[t_] := Product[t - x[k], {k, 0, n}];
- Do[w[k_, t_] := w[t]/(t - x[k]), {k, 0, n}];
- Do[l[k_, t_] := w[k, t]/Simplify[w[k, t] /. t -> x[k]], {k, 0, n}];
- L[f_, t_] := Sum[f[x[k]]*l[k, t], {k, 0, n}];
- m = Expand[L[f, t]]
- Plot[Abs[f[t] - m], {t, 0, 1}, PlotRange -> All]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement