


'''simple docstring'''
from collections.abc import Callable


def       _lowercase							(					UpperCamelCase__							:       Callable[[float], float],					UpperCamelCase__							:       float,					UpperCamelCase__							:       float      ):
 __A	:		List[str]	  =      a
 __A	:		List[str]	  =      b
 if function(_snake_case      ) == 0:  # one of the a or b is a root for the function
  return a
 elif function(_snake_case      ) == 0:
  return b
 elif (
     function(_snake_case      ) * function(_snake_case      ) > 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	:		Any	  =      start + (end - start) / 2.0
  while abs(start - mid      ) > 10**-7:  # until precisely equals to 10^-7
   if function(_snake_case      ) == 0:
    return mid
   elif function(_snake_case      ) * function(_snake_case      ) < 0:
    __A	:		Optional[Any]	  =      mid
   else:
    __A	:		str	  =      mid
   __A	:		int	  =      start + (end - start) / 2.0
  return mid


def       _lowercase							(					UpperCamelCase__							:       float      ):
 return x**3 - 2 * x - 5


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

 import doctest

 doctest.testmod()












"""simple docstring"""

import math






def 		_snake_case	(   _snake_case				:   float							,    _snake_case				:   float				)       ->   float:






      '''simple docstring'''


      if (
          not isinstance(_snake_case							,    (int, float)				)
          or power_factor < -1
          or power_factor > 1
      ):
            raise ValueError('power_factor must be a valid float value between -1 and 1.'				)
      return apparent_power * power_factor






def 		_snake_case	(   _snake_case				:   float							,    _snake_case				:   float				)       ->   float:






      '''simple docstring'''


      if (
          not isinstance(_snake_case							,    (int, float)				)
          or power_factor < -1
          or power_factor > 1
      ):
            raise ValueError('power_factor must be a valid float value between -1 and 1.'				)
      return apparent_power * math.sqrt(1 - power_factor**2				)


if __name__ == "__main__":
       import doctest

       doctest.testmod()

