




"""simple docstring"""




from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403







def      __UpperCAmelCase     ( __UpperCamelCase	,				__UpperCamelCase	,				__UpperCamelCase = "x"	,				__UpperCamelCase = 10**-10	,				__UpperCamelCase = 1	,				):
			__lowercase			:  List[Any]								=       symbols(__UpperCamelCase	)
			__lowercase			:  List[Any]								=       lambdify(__UpperCamelCase	,				__UpperCamelCase	)
			__lowercase			:  Optional[int]								=       lambdify(__UpperCamelCase	,				diff(__UpperCamelCase	,				__UpperCamelCase	)	)

			__lowercase			:  Dict								=       starting_point

			while True:
						if diff_function(__UpperCamelCase	) != 0:
									__lowercase			:  List[str]								=       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

						__lowercase			:  int								=       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', 1_0, precision=0.005)}",
			)

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






'''simple docstring'''



def       snake_case   (	snake_case      : dict			) ->  set:


    """simple docstring"""


    lowerCAmelCase 						=							set()
    # edges = list of graph's edges
    lowerCAmelCase 						=							get_edges(snake_case			)

    # While there are still elements in edges list, take an arbitrary edge
    # (from_node, to_node) and add his extremity to chosen_vertices and then
    # remove all arcs adjacent to the from_node and to_node
    while edges:
        lowerCAmelCase						,   lowerCAmelCase 						=							edges.pop()
        chosen_vertices.add(snake_case			)
        chosen_vertices.add(snake_case			)
        for edge in edges.copy():
            if from_node in edge or to_node in edge:
                edges.discard(snake_case			)
    return chosen_vertices


def       snake_case   (	snake_case      : dict			) ->  set:


    """simple docstring"""


    lowerCAmelCase 						=							set()
    for from_node, to_nodes in graph.items():
        for to_node in to_nodes:
            edges.add((from_node, to_node)			)
    return edges


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     # graph = {0: [1, 3], 1: [0, 3], 2: [0, 3, 4], 3: [0, 1, 2], 4: [2, 3]}
     # print(f"Matching vertex cover:\n{matching_min_vertex_cover(graph)}")





