
from collections.abc import Callable


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


def 			UpperCamelCase					(    __lowerCamelCase     : float    ):
       return x**3 - 2 * x - 5


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

   import doctest

   doctest.testmod()







__lowerCamelCase							=       {
    "joule": 1.0,
    "kilojoule": 10_00,
    "megajoule": 1_00_00_00,
    "gigajoule": 10_00_00_00_00,
    "wattsecond": 1.0,
    "watthour": 36_00,
    "kilowatthour": 3_60_00_00,
    "newtonmeter": 1.0,
    "calorie_nutr": 41_86.8,
    "kilocalorie_nutr": 4_18_68_00.00,
    "electronvolt": 1.602_176_634e-19,
    "britishthermalunit_it": 10_55.0_55_85,
    "footpound": 1.35_5818,
}


def 			UpperCamelCase					(    __lowerCamelCase     : str				,					__lowerCamelCase     : str				,					__lowerCamelCase     : float    ):
       if to_type not in ENERGY_CONVERSION or from_type not in ENERGY_CONVERSION:
              snake_case       :   List[Any]							=      (
                  f"""Incorrect 'from_type' or 'to_type' value: {from_type!r}, {to_type!r}\n"""
                  f"""Valid values are: {', '.join(__lowerCamelCase    )}"""
              )
              raise ValueError(__lowerCamelCase    )
       return value * ENERGY_CONVERSION[from_type] / ENERGY_CONVERSION[to_type]


if __name__ == "__main__":
   import doctest

   doctest.testmod()





