function [p] = hw3afn(p0,p1,N)

   if p0 < p1
      a = p0;
      b = p1;
   else
      a = p1;
      b = p0;
   end

   fa = hw1afn(a);
   fb = hw1afn(b);
   for n = 2:N
      p = b-fb*(b-a)/(fb-fa);
      fp = hw1afn(p);
      if fa*fp <= 0
         b = p;
         fb = fp;
      else
         a = p;
         fa = fp;
      end
   end

end
