

from collections.abc import Callable




def 			UpperCAmelCase__				(			_A      : Callable[[float], float]	,      _A      : float	,      _A      : float							):





  '''simple docstring'''







  a__  =a
  a__  =b
  if function(_A							) == 0:  # one of the a or b is a root for the function
    return a
  elif function(_A							) == 0:
    return b
  elif (
      function(_A							) * function(_A							) > 0
  ):  # if none of these are root and they are both positive or negative,
    # then this algorithm can't find the root
    raise ValueError('''could not find root in given interval.'''							)
  else:
    a__  =start + (end - start) / 2.0
    while abs(start - mid							) > 10**-7:  # until precisely equals to 10^-7
      if function(_A							) == 0:
        return mid
      elif function(_A							) * function(_A							) < 0:
        a__  =mid
      else:
        a__  =mid
      a__  =start + (end - start) / 2.0
    return mid




def 			UpperCAmelCase__				(			_A      : float							):





  '''simple docstring'''







  return x**3 - 2 * x - 5


if __name__ == "__main__":
       print(bisection(f, 1, 1000))

       import doctest

       doctest.testmod()



from __future__ import annotations




def 			UpperCAmelCase__				(			_A      : float	,      _A      : float	,      _A      : float	,      ):





  '''simple docstring'''







  if (electron_conc, hole_conc, intrinsic_conc).count(0							) != 1:
    raise ValueError('''You cannot supply more or less than 2 values'''							)
  elif electron_conc < 0:
    raise ValueError('''Electron concentration cannot be negative in a semiconductor'''							)
  elif hole_conc < 0:
    raise ValueError('''Hole concentration cannot be negative in a semiconductor'''							)
  elif intrinsic_conc < 0:
    raise ValueError(
        '''Intrinsic concentration cannot be negative in a semiconductor'''							)
  elif electron_conc == 0:
    return (
        "electron_conc",
        intrinsic_conc**2 / hole_conc,
    )
  elif hole_conc == 0:
    return (
        "hole_conc",
        intrinsic_conc**2 / electron_conc,
    )
  elif intrinsic_conc == 0:
    return (
        "intrinsic_conc",
        (electron_conc * hole_conc) ** 0.5,
    )
  else:
    return (-1, -1)


if __name__ == "__main__":
       import doctest

       doctest.testmod()
