You are on page 1of 1

function [x dx]=horner(a,r)

n=length(a);
b(1)=a(1);
c(1)=b(1);
for i=2:n
b(i)=a(i)+b(i-1)*r;
c(i)=b(i)+c(i-1)*r;
end
x=b(n);
dx=c(n-1);

You might also like