




import math



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			int			,				__lowercase   :			Tuple = 0			,				__lowercase   :			Union[str, Any] = 0    )						->      list:





    """simple docstring"""

    __A         =	end or len(SCREAMING_SNAKE_CASE_    )
    for i in range(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_    ):
        __A         =	i
        __A         =	array[i]
        while temp_index != start and temp_index_value < array[temp_index - 1]:
            __A         =	array[temp_index - 1]
            temp_index -= 1
        __A         =	temp_index_value
    return array



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			Tuple			,				__lowercase   :			Union[str, Any]			,				__lowercase   :			str    )						->      None:  # Max Heap





    """simple docstring"""

    __A         =	index
    __A         =	2 * index + 1  # Left Node
    __A         =	2 * index + 2  # Right Node

    if left_index < heap_size and array[largest] < array[left_index]:
        __A         =	left_index

    if right_index < heap_size and array[largest] < array[right_index]:
        __A         =	right_index

    if largest != index:
        __A    ,	__A         =	array[largest], array[index]
        heapify(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_    )



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			Optional[int]    )						->      list:





    """simple docstring"""

    __A         =	len(SCREAMING_SNAKE_CASE_    )

    for i in range(n // 2			,				-1			,				-1    ):
        heapify(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_    )

    for i in range(n - 1			,				0			,				-1    ):
        __A    ,	__A         =	array[0], array[i]
        heapify(SCREAMING_SNAKE_CASE_			,				0			,				SCREAMING_SNAKE_CASE_    )

    return array



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			List[str]			,				__lowercase   :			str			,				__lowercase   :			Tuple			,				__lowercase   :			Optional[Any]    )						->      int:





    """simple docstring"""

    if (array[first_index] > array[middle_index]) != (
        array[first_index] > array[last_index]
    ):
        return array[first_index]
    elif (array[middle_index] > array[first_index]) != (
        array[middle_index] > array[last_index]
    ):
        return array[middle_index]
    else:
        return array[last_index]



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			List[str]			,				__lowercase   :			Optional[int]			,				__lowercase   :			Optional[int]			,				__lowercase   :			List[str]    )						->      int:





    """simple docstring"""

    __A         =	low
    __A         =	high
    while True:
        while array[i] < pivot:
            i += 1
        j -= 1
        while pivot < array[j]:
            j -= 1
        if i >= j:
            return i
        __A    ,	__A         =	array[j], array[i]
        i += 1



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			Dict    )						->      list:





    """simple docstring"""

    if len(SCREAMING_SNAKE_CASE_    ) == 0:
        return array
    __A         =	2 * math.ceil(math.loga(len(SCREAMING_SNAKE_CASE_    )    )    )
    __A         =	1_6
    return intro_sort(SCREAMING_SNAKE_CASE_			,				0			,				len(SCREAMING_SNAKE_CASE_    )			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_    )



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			Optional[int]			,				__lowercase   :			List[Any]			,				__lowercase   :			str			,				__lowercase   :			Dict			,				__lowercase   :			Dict    )						->      list:





    """simple docstring"""

    while end - start > size_threshold:
        if max_depth == 0:
            return heap_sort(SCREAMING_SNAKE_CASE_    )
        max_depth -= 1
        __A         =	median_of_a(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				start + ((end - start) // 2) + 1			,				end - 1    )
        __A         =	partition(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_    )
        intro_sort(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_    )
        __A         =	p
    return insertion_sort(SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_			,				SCREAMING_SNAKE_CASE_    )


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  __a      :       Optional[Any]				  =   input("Enter numbers separated by a comma : ").strip()
  __a      :       Optional[int]				  =   [float(item) for item in user_input.split(",")]
  print(sort(unsorted))












from __future__ import annotations

from decimal import Decimal
from math import *  # noqa: F403

from sympy import diff



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			str			,				__lowercase   :			float | Decimal			,				__lowercase   :			float = 1_0**-1_0    )						->      float:





    """simple docstring"""

    __A         =	a
    while True:
        __A         =	Decimal(__lowercase    ) - (
            Decimal(eval(__lowercase    )    ) / Decimal(eval(str(diff(__lowercase    )    )    )    )  # noqa: S307
        )
        # This number dictates the accuracy of the answer
        if abs(eval(__lowercase    )    ) < precision:  # noqa: S307
            return float(__lowercase    )


# Let's Execute
if __name__ == "__main__":
  # Find root of trigonometric function
  # Find value of pi
  print(f"""The root of sin(x) = 0 is {newton_raphson('sin(x)', 2)}""")
  # Find root of polynomial
  print(f"""The root of x**2 - 5*x + 2 = 0 is {newton_raphson('x**2 - 5*x + 2', 0.4)}""")
  # Find Square Root of 5
  print(f"""The root of log(x) - 1 = 0 is {newton_raphson('log(x) - 1', 2)}""")
  # Exponential Roots
  print(f"""The root of exp(x) - 1 = 0 is {newton_raphson('exp(x) - 1', 0)}""")




