




"""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 				lowercase__		(					lowerCamelCase,						lowerCamelCase       ):
				return abs(lowerCamelCase       ) if a == 0 else greatest_common_divisor(b % a,						lowerCamelCase       )





def 				lowercase__		(					lowerCamelCase,						lowerCamelCase       ):
				while y:  # --> when y=0 then loop will terminate and return x as final GCD.
								_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    y, x % y
				return abs(lowerCamelCase       )





def 				lowercase__		(					):
				try:
								_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    input('Enter two integers separated by comma (,): '       ).split(','       )
								_SCREAMING_SNAKE_CASE   :		Dict       		=    int(nums[0]       )
								_SCREAMING_SNAKE_CASE   :		Dict       		=    int(nums[1]       )
								print(
								    f"""greatest_common_divisor({num_a}, {num_a}) = """
								    f"""{greatest_common_divisor(lowerCamelCase,						lowerCamelCase       )}"""       )
								print(f"""By iterative gcd({num_a}, {num_a}) = {gcd_by_iterative(lowerCamelCase,						lowerCamelCase       )}"""       )
				except (IndexError, UnboundLocalError, ValueError):
								print('Wrong input'       )


if __name__ == "__main__":
			main()

