%computes and displays the coefficients of (P(x)-P(r))/(x-r), 
%where P(x)=a(1)+a(2)*x+...+a(n+1)*x^n at x=r, and n+1=length(a)

a = [3,-4,-1,1]           %coefficients of P(x)
n = length(a)-1;
b = zeros(1,length(a));   %initializes b as b = [0,...,0];
r = 2;                    
b(n+1) = a(n+1);              %leading coefficient

for i=n:-1:1
    b(i) = b(i+1)*r+a(i);
end

disp('coeffs are...')
b

