function p5
  disp('Part a)')
  secant(1, 2, @f, 5, sqrt(3))
  disp('Part b)')
  secant(3, 4, @f, 7, sqrt(15))
end
function y = f(x)
  y = x^4-18*x^2+45;
end
function secant(x0, x1, f, itcount, true)
  this = x1;
  last = x0;
  for i=1:itcount
    new = this - f(this)*(this-last)/(f(this)-f(last));
    last = this;
    this = new;
    disp(sprintf('Iteration:%d value:%.10g error:%.10e', i, this, abs(this-true)))
    errors(i) = abs(this-true);
  end

  order_of_convergence(errors)
end

function order_of_convergence(seq)
  for at=1:length(seq)-1
    order = log(seq(at+1)) / log(seq(at+0));
    disp(sprintf('Apparent order of convergence at iteration %d:%g', at, order))
  end
end
