﻿function [p, pprime, q] = DannyHorner(x0,c)
n=length(c);
i=2;
result = c(1);
newcoefs = [];


  while (i<=n)
    newcoefs = [newcoefs, result];
    result = c(i) + result*x0;
    %disp (result)
    i++;
  endwhile

%implement the suggestion I made during class right before it adsds the p(t) in the next line, and just exports it for newton to handle
q=newcoefs;
newcoefs = [newcoefs, result];

p = result;
%disp (p)

result = newcoefs(1);
newnewcoefs = [];
i=2;
while (i<=(n-1))
    newnewcoefs = [newnewcoefs, result];
    result = newcoefs(i) + result*x0;
    %disp (result)
    i++;
endwhile
newnewcoefs = [newnewcoefs, result];

pprime = result;

%disp(p)
%disp (pprime)

end