


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

			UpperCamelCase__					=       starting_point

			while True:
						if diff_function(_A  ) != 0:
									UpperCamelCase__					=       prev_guess - multiplicity * func(_A  ) / diff_function(
									    _A  )
						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", 1_0, precision=0.005)}''',
						)

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






def        UpperCamelCase_(				_A   :str  )->		int:
			UpperCamelCase__					=       hex_num.strip()
			if not hex_num:
						raise ValueError("No value was passed to the function"  )

			UpperCamelCase__					=       hex_num[0] == "-"
			if is_negative:
						UpperCamelCase__					=       hex_num[1:]

			try:
						UpperCamelCase__					=       int(_A				,     16  )
			except ValueError:
						raise ValueError("Invalid value was passed to the function"  )

			UpperCamelCase__					=       ""
			while int_num > 0:
						UpperCamelCase__					=       str(int_num % 2  ) + bin_str
						int_num >>= 1

			return int(("-" + bin_str) if is_negative else bin_str  )


if __name__ == "__main__":
						import doctest

						doctest.testmod()


