


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

def 					lowerCamelCase_ ( __UpperCamelCase					:       Callable[[float], float]							,    __UpperCamelCase					:       float							,    __UpperCamelCase					:       float		)					->	float:







     """simple docstring"""
     _A				=							a
     _A				=							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:
          _A				=							start + (end - start) / 2.0
          while abs(start - mid		) > 1_0**-7:  # until precisely equals to 10^-7
               if function(__UpperCamelCase		) == 0:
                    return mid
               elif function(__UpperCamelCase		) * function(__UpperCamelCase		) < 0:
                    _A				=							mid
               else:
                    _A				=							mid
               _A				=							start + (end - start) / 2.0
          return mid

def 					lowerCamelCase_ ( __UpperCamelCase					:       float		)					->	float:







     """simple docstring"""
     return x**3 - 2 * x - 5


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

    import doctest

    doctest.testmod()









'''simple docstring'''
from __future__ import annotations

def 					lowerCamelCase_ ( __UpperCamelCase					:       list							,    __UpperCamelCase					:       int | None = None							,    __UpperCamelCase					:       int | None = None		)					->	None:







     """simple docstring"""
     if start is None:
          _A				=							0

     if end is None:
          _A				=							len(__UpperCamelCase		) - 1

     if start >= end:
          return

     _A				=							(start + end) // 2

     slowsort(__UpperCamelCase							,    __UpperCamelCase							,    __UpperCamelCase		)
     slowsort(__UpperCamelCase							,    mid + 1							,    __UpperCamelCase		)

     if sequence[end] < sequence[mid]:
          _A		,				_A				=							sequence[mid], sequence[end]

     slowsort(__UpperCamelCase							,    __UpperCamelCase							,    end - 1		)


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

    testmod()





