Plot the Newton polynomial for the points \((k, \arctan k)\text{,}\) \(k=-5, \dots, 5\text{.}\) Then repeat with 5 replaced by 8.
Answer.
x = -5:5;
n = numel(x);
y = atan(x);
c = y;
for k=2:n
c(k:n) = (c(k:n)-c(k-1))./(x(k:n)-x(k-1));
end
t = linspace(min(x)-0.01, max(x)+0.01, 1000);
p = c(n)*ones(size(t));
for k=n-1:-1:1
p = p.*(t-x(k)) + c(k);
end
plot(t, p, x, y, 'r*')
