function x_star = bisect_eq2( x_lft, x_rgt )
%
%   Find a solution to the equation f(x) = exp( x ) - 3 x^2 = 0
%   using the method of bisection.  Begin with the interval
%    [ x_lft, x_rgt ] and return the solution accurate to 0.5e-5

  f_lft = exp( x_lft ) - 3*x_lft^2;   %   f(x_lft)
  f_rgt = exp( x_rgt ) - 3*x_rgt^2;   %   f(x_rgt)

  while ( x_rgt - x_lft ) > 1.0e-5
                                         %      LOOP ---+
    x_mp = 0.5*( x_lft + x_rgt );  % the midpoint       |
    f_mp = exp( x_mp ) - 3*x_mp^2; %  f(x_mp)           |
                                   %                    |
                     %  replace that end with           |
                     %  the same sign as f(x_mp)        |
    if f_mp*f_lft > 0.0            %                    |
              % f(x_mp) is same sign as f(x_lft)...     |
      x_lft = x_mp;  %   replace x_lft                  |
      f_lft = f_mp;  %   and f(x_lft)                   |
    else                           %                    |
              % f(x_mp) is same sign as f(x_rgt)...     |
      x_rgt = x_mp;  %  replace x_rgt                   |
      f_rgt = f_mp;  %  and f(x_rgt)                    |
   end        % end of if - else statement              |
                                   %         -----------+
  end   %

  x_star = 0.5*( x_lft + x_rgt );   %     the value to return
