function [x,t,e] = steffensen(f,x0,TOL,N0)

  tic;
  i=1;
  A=x0;
  B=f(A);


  while (i<=N0)
      %first bit here is just getting 3 initial values by plugging in equation a few times
    x0=A;
    x1=B;
    x2=f(x1);
    if (abs(x2-x1)<TOL)

      x=x2;
      t = toc;
      e = i-1;
      return
    end%if
    %once u have some values u can now use aitkens to get the good approximation
    x=x0-(x1-x0)^2/(x2-2*x1+x0)
    if (abs(x-x2)<TOL)
      x=x2;
      t = toc;
      e = i-1;
      return
    end%if
    %this part now sets the new values for the next iteration, turning the aitkens into a steffensons
    A=x;
    B=f(A);
    i=i+1;
  end%while
  x=NaN;
  t =NaN;
  e=NaN;
end%function
