Advertisement
kachamaka

ЧА-2

Oct 11th, 2022 (edited)
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. n = 5;
  2. f[t_] := 1/(1 + t);
  3. Do[x[k] = k/n, {k, 0, n}];
  4. w[t_] := Product[t - x[k], {k, 0, n}];
  5. Do[w[k_, t_] := w[t]/(t - x[k]), {k, 0, n}];
  6. Do[l[k_, t_] := w[k, t]/Simplify[w[k, t] /. t -> x[k]], {k, 0, n}];
  7. L[f_, t_] := Sum[f[x[k]]*l[k, t], {k, 0, n}];
  8. m = Expand[L[f, t]]
  9. Plot[Abs[f[t] - m], {t, 0, 1}, PlotRange -> All]
  10.  
  11. n = 5;
  12. f[t_] := 1/(1 + t);
  13. Do[x[k] = (Sin[(2*k + 1)*Pi/(4 n + 4)])^2, {k, 0, n}];
  14. w[t_] := Product[t - x[k], {k, 0, n}];
  15. Do[w[k_, t_] := w[t]/(t - x[k]), {k, 0, n}];
  16. Do[l[k_, t_] := w[k, t]/Simplify[w[k, t] /. t -> x[k]], {k, 0, n}];
  17. L[f_, t_] := Sum[f[x[k]]*l[k, t], {k, 0, n}];
  18. m = Expand[L[f, t]]
  19. Plot[Abs[f[t] - m], {t, 0, 1}, PlotRange -> All]
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement