





from collections.abc import Callable






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






def 							_lowerCAmelCase (  _a   :					float			)	->			Any:
     return x**3 - 2 * x - 5


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

      import doctest

      doctest.testmod()












from collections.abc import Sequence






def 							_lowerCAmelCase (  _a   :					Sequence[float]					,   _a   :					bool = False			)	->			float:
     if not arr:
          return 0

     lowerCAmelCase_					:       List[str]    =		0 if allow_empty_subarrays else float("""-inf"""			)
     lowerCAmelCase_					:       List[Any]    =		0.0
     for num in arr:
          lowerCAmelCase_					:       int    =		max(0 if allow_empty_subarrays else num					,   curr_sum + num			)
          lowerCAmelCase_					:       List[str]    =		max(_a					,   _a			)

     return max_sum


if __name__ == "__main__":
      from doctest import testmod

      testmod()

      UpperCAmelCase_					:   int 							=						[-2, 1, -3, 4, -1, 2, 1, -5, 4]
      print(F"""{max_subarray_sum(nums) = }""")
