function myBisection(func,a,b)
% :::::::::::::::::: Bisektion-Methode    :::::::::::::::::::::::
close all;
% clear;
disp(['°°°°°°°°°°°° S T A R T °°°°°°°°°°°°°°°°°°°° ',date,' °°°°°°°°°°°°°°°°°°°°°'])
% ::::::::::::::::::::::::::::::::::::::
%  func = inline('-x.^2+2*x+2');                                                  % die 1. y-Funktion
%  func = inline('x.^3-5*x');                                                       % die 2. y-Funktion
% func = inline('x.^3-sqrt(x.^2+1)')                                           % die 3. y-Funktion
% :::::::::::::::::::::::::::::: 1. Abbruchbed.:
if  a>b ;
    hw = warndlg('Error - Intervall [a] & [b] must be distinct [a] < [b] ');
    set(hw,'color','c');
    return;
end
% ::::::::::::::::::::::::::::::::::::::::::::::::::::.
% a = -5;                                       %  lower Limit of Intervall on X
% b =  5;                                       %  upper Limit of Intervall on X
tol = 1e-6;                                     %  Genauigkeit, Abweichg. von Nullstelle, root
% ::::::::::::::::::::::
fa = func(a);
fb = func(b);                                       % get the Y-Values
fprintf('Intervall-Y-Coords [fa], [fb] : %10.2f  %10.2f \n', fa,fb);
% ::::::::::::::::::: Intervall-Mitte ::::::::::::::
m1 = (a+b)*1/2;
fm1 = func(m1);
fprintf('1.Intervall-Mitte  [m], [fm] : %10.2f  %10.2f \n', m1,fm1);
% :::::::::::::::::::::::::::: 2. Abbruchbed.:
if sign(fa)==sign(fb) && sign(fm1)==sign(fa)
      hw = warndlg('Intervall - Error : Function do not cross X-Axis !!!');
      set(hw,'color','g');
      return
end
% :::::::::::::.
k = 0;
tic,
while abs(b-a) > tol
% ::::::: Intervall-Mitte ::::::::::::::
m = (a+b)*1/2;
fm = func(m);
% ::::::::::::::::::::::::::::::::
      if fm ==0
          Nullstelle = m
          k = k+1;
          % ::::::::::::::::::::::: Graphic-Plot :::::::::::::::::.
          ezplot(func,[a b])
          grid
          h = findobj(gca, 'Type', 'line');
          set(h, 'color', 'b','Linewidth', 2);
          set(gca, 'color', 'none', 'Fontsize', 14, 'Fontweight', 'bold');
          set(get(gca,'title'),'Fontweight', 'bold', 'color', 'b', 'Fontsize', 16);
          hold on
          plot(m,0,'r*','MarkerSize', 14, 'Linewidth',1.5)
          disp('^^^^^^^^^^^^^^^^ end ^^^^^^^^^^^^^^^^')
          return
       elseif  fa*fm > 0             % if sign Change
          a = m;
         fa = fm;
      else                              % if not sign Change
          b = m;
         fb = fm;  
     end
       k = k+1;
 end
 Time = toc;
 fprintf('elapsed time : %12.3f \n', Time);
 fprintf('Toleranz : %15.3g \n', tol);
 fprintf('Nullstelle : %15.6f \n', m);
 fprintf(' Iteration : %15.f \n', k);
disp('^^^^^^^^^^^^^^^^ end ^^^^^^^^^^^^^^^^')
% :::::::::::::::::::::: Graphic - Plot ::::::::::::::::::
ezplot(func, [-0.4 0.4])
   grid
   h = findobj(gca, 'Type', 'line');
   set(h, 'color', 'b','Linewidth', 2);
   set(gca, 'color', 'none', 'Fontsize', 14, 'Fontweight', 'bold');
   line( 0*[1,1] ,get(gca,'Ylim'), 'color', 'k', 'linewidth',1.5 );
   line( get(gca,'Xlim'), 0*[1,1],'color', 'k', 'linewidth',1.5 );
   set(get(gca,'title'),'Fontweight', 'bold', 'color', 'b','Fontsize', 16);
   hold on
   plot(m,0,'r*','MarkerSize', 12, 'Linewidth', 2)

% ::::::::::::::::::::::::::.
