Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- X = [-8 -2 3 11];
- Y = [2 7 9 4];
- plot2d(X, Y, -1, leg="Точки");
- Y5 = [];
- n = 3;
- C = [];
- C(1) = Y(1);
- for i = 1:n
- s = Y(i+1) - C(1);
- for j = 1:i-1
- p = 1;
- for k = 0:j-1
- p = p * (X(i+1) - X(k+1));
- end
- s = s - p;
- end
- for j = 0:i-1
- s = s / (X(i+1) - X(j+1));
- end
- C(i+1) = s;
- end
- for x = -15:15
- s = C(1);
- for i = 1:n
- p = C(i+1);
- for j = 0:i-1
- p = p * (x - X(j+1));
- end
- s = s + p;
- end
- Y5 = [Y5, s];
- end
- plot2d(-15:15, Y5, style=[color("magenta")], leg="Метод Ньютона");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement