﻿function [x,q] = DannyNewtonHorner(c,x0,TOL,N)

  i=1;
  while (i<=N)
    #just newtons with an extra line that iomplements horners for f and fp

    [f, fp, q] = DannyHorner(x0, c);

    x=x0-f/fp;
    #this piece tells us when to exit the code 
    if (abs(x-x0)<TOL)
      return
    end%if
    i=i+1;
    x0=x;
  endwhile
  % disp (q)
  #and if max its runs out we get this bit
  x="Method failed---maximum number of iterations reached";
  
end%function