## Copyright (C) 2011 rudiger.achilles
## 
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## 
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <http://www.gnu.org/licenses/>.

## bi

## Author: rudiger.achilles <rudiger.achilles@RED41>
## Created: 2011-10-28

function [ z ] = bi (f, a, b)
m = a + (b-a)/2;
  for k = 1:100
    if f(m) == 0 z=m; return;
      elseif sign(f(m))==sign(f(a)) a = m; m = a + (b-a)/2;
	  else b = m; m = a + (b-a)/2;
	end
  end;
  z = m;
endfunction

