


from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403
def 							__lowerCamelCase		(					UpperCAmelCase_		:						str					,    UpperCAmelCase_		:						complex					,    UpperCAmelCase_		:						str = "x"					,    UpperCAmelCase_		:						float = 10**-10					,    UpperCAmelCase_		:						int = 1					,    ):




      """simple docstring"""





      a		:List[Any]									=			symbols(UpperCAmelCase_		)
      a		:Any									=			lambdify(UpperCAmelCase_					,    UpperCAmelCase_		)
      a		:List[Any]									=			lambdify(UpperCAmelCase_					,    diff(UpperCAmelCase_					,    UpperCAmelCase_		)		)

      a		:Optional[int]									=			starting_point

      while True:
            if diff_function(UpperCAmelCase_		) != 0:
                  a		:Tuple									=			prev_guess - multiplicity * func(UpperCAmelCase_		) / diff_function(
                      UpperCAmelCase_		)
            else:
                  raise ZeroDivisionError('''Could not find root'''		) from None

            # Precision is checked by comparing the difference of consecutive guesses
            if abs(next_guess - prev_guess		) < precision:
                  return next_guess

            a		:str									=			next_guess


# 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
     # Find fourth Root of 5
     print(F"""The root of x**4 - 5 = 0 is {newton_raphson("x**4 -5", 0.4 +5j)}""")

     # Find value of e
     print(
         '''The root of log(y) - 1 = 0 is ''',
         F"""{newton_raphson("log(y) - 1", 2, variable="y")}""",
     )

     # Exponential Roots
     print(
         '''The root of exp(x) - 1 = 0 is''',
         F"""{newton_raphson("exp(x) - 1", 10, precision=0.0_05)}""",
     )

     # Find root of cos(x)
     print(F"""The root of cos(x) = 0 is {newton_raphson("cos(x)", 0)}""")









snake_case							:       Any										=	{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

snake_case							:       Any										=	{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}
def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]					,    UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						list[bool]		):




      """simple docstring"""





      a		:Any									=			True
      a		:Any									=			[]

      for neighbour in graph[vert]:
            if not visited[neighbour]:
                  order += topology_sort(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)

      order.append(UpperCAmelCase_		)

      return order
def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]					,    UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						list[bool]		):




      """simple docstring"""





      a		:Optional[Any]									=			True
      a		:int									=			[vert]

      for neighbour in reversed_graph[vert]:
            if not visited[neighbour]:
                  component += find_components(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)

      return component






def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]		):




      """simple docstring"""





      a		:int									=			len(UpperCAmelCase_		) * [False]
      a		:dict[int, list[int]]									=			{vert: [] for vert in range(len(UpperCAmelCase_		)		)}

      for vert, neighbours in graph.items():
            for neighbour in neighbours:
                  reversed_graph[neighbour].append(UpperCAmelCase_		)

      a		:Optional[Any]									=			[]
      for i, was_visited in enumerate(UpperCAmelCase_		):
            if not was_visited:
                  order += topology_sort(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)

      a		:Tuple									=			[]
      a		:int									=			len(UpperCAmelCase_		) * [False]

      for i in range(len(UpperCAmelCase_		)		):
            a		:Union[str, Any]									=			order[len(UpperCAmelCase_		) - i - 1]
            if not visited[vert]:
                  a		:Union[str, Any]									=			find_components(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)
                  components_list.append(UpperCAmelCase_		)

      return components_list





