%first algorithm for interpolating y_i = f(x_i)

x = [1,-4,0];     %vector of x_i's
y = [3,13,-23];   %vector of y_i's

n = length(x);
b = zeros(1,n);
b(1) = y(1);      %b(i) = f[x_1,...x_i] is ith divided difference

for k=2:n
    p = 0;
    q = 1;
    for i=1:k-1
        p = p + b(i)*q;
        q = q*(x(k)-x(i));
    end
    b(k) = (y(k)-p)/q;
end

disp('the divided differences are')
b




    

