
def 							__A(lowerCAmelCase						,  lowerCAmelCase )		->				int:

		"""simple docstring"""






		while a != 0:
				_UpperCamelCase    ,	_UpperCamelCase						    =	b % a, a
		return b







def 							__A(lowerCAmelCase						,  lowerCAmelCase )		->				int:

		"""simple docstring"""






		if gcd(lowerCAmelCase						,  lowerCAmelCase ) != 1:
				_UpperCamelCase						    =	F'mod inverse of {a!r} and {m!r} does not exist'
				raise ValueError(lowerCAmelCase )
		_UpperCamelCase    ,	_UpperCamelCase    ,	_UpperCamelCase						    =	1, 0, a
		_UpperCamelCase    ,	_UpperCamelCase    ,	_UpperCamelCase						    =	0, 1, m
		while va != 0:
				_UpperCamelCase						    =	ua // va
				_UpperCamelCase    ,	_UpperCamelCase    ,	_UpperCamelCase    ,	_UpperCamelCase    ,	_UpperCamelCase    ,	_UpperCamelCase						    =	(ua - q * va), (ua - q * va), (ua - q * va), va, va, va
		return ua % m





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


def 							__A(lowerCAmelCase						,  lowerCAmelCase						,  lowerCAmelCase = "x"						,  lowerCAmelCase = 1_0**-1_0						,  lowerCAmelCase = 1						,  )		->				complex:

		"""simple docstring"""






		_UpperCamelCase						    =	symbols(lowerCAmelCase )
		_UpperCamelCase						    =	lambdify(lowerCAmelCase						,  lowerCAmelCase )
		_UpperCamelCase						    =	lambdify(lowerCAmelCase						,  diff(lowerCAmelCase						,  lowerCAmelCase ) )

		_UpperCamelCase						    =	starting_point

		while True:
				if diff_function(lowerCAmelCase ) != 0:
						_UpperCamelCase						    =	prev_guess - multiplicity * func(lowerCAmelCase ) / diff_function(
						    lowerCAmelCase )
				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

				_UpperCamelCase						    =	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)}""")



