function [tnew] = reg_falsi(t,f)
%
%  This routine performs one iteration step of regula falsi
%    t is the vector of times: t = [t1,t2]
%    f is the matrix of zero-crossing function values: f = [f1,f2]
%    tnew is the next evaluation time
%
%  We start by unpacking the input variables
%
t1 = t(1);
t2 = t(2);
f1 = f(:,1);
f2 = f(:,2);
%
%  we need to check which of the zero-crossing functions are currently
%  active
%
[n,m] = size(f);
tnew = 2*t2;
for i=1:n,
  if f1(i)*f2(i) < 0,
    tnew = min([tnew,(f2*t1 - f1*t2)/(f2 - f1)]);
  end,
end
%
%  If no zero-crossing function was active, return -1
%
if tnew > t2,
  tnew = -1;
end
%
return