





from collections.abc import Generator
from math import sin




def _a (  SCREAMING_SNAKE_CASE__      :  bytes       )	->    bytes:

							'''simple docstring'''






							if len(SCREAMING_SNAKE_CASE__       ) != 32:
														raise ValueError("Input must be of length 32"       )

							SCREAMING_SNAKE_CASE__       :      Dict     =						b""
							for i in [3, 2, 1, 0]:
														little_endian += string_aa[8 * i : 8 * i + 8]
							return little_endian




def _a (  SCREAMING_SNAKE_CASE__      :  int       )	->    bytes:

							'''simple docstring'''






							if i < 0:
														raise ValueError("Input must be non-negative"       )

							SCREAMING_SNAKE_CASE__       :      List[str]     =						format(SCREAMING_SNAKE_CASE__			,				"08x"       )[-8:]
							SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						b""
							for i in [3, 2, 1, 0]:
														little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode("utf-8"       )
							return little_endian_hex




def _a (  SCREAMING_SNAKE_CASE__      :  bytes       )	->    bytes:

							'''simple docstring'''






							SCREAMING_SNAKE_CASE__       :      Any     =						b""
							for char in message:
														bit_string += format(SCREAMING_SNAKE_CASE__			,				"08b"       ).encode("utf-8"       )
							SCREAMING_SNAKE_CASE__       :      str     =						format(len(SCREAMING_SNAKE_CASE__       )			,				"064b"       ).encode("utf-8"       )

							# Pad bit_string to a multiple of 512 chars
							bit_string += b"1"
							while len(SCREAMING_SNAKE_CASE__       ) % 5_12 != 4_48:
														bit_string += b"0"
							bit_string += to_little_endian(start_len[32:]       ) + to_little_endian(start_len[:32]       )

							return bit_string




def _a (  SCREAMING_SNAKE_CASE__      :  bytes       )	->    Generator[list[int], None, None]:

							'''simple docstring'''






							if len(SCREAMING_SNAKE_CASE__       ) % 5_12 != 0:
														raise ValueError("Input must have length that's a multiple of 512"       )

							for pos in range(0			,				len(SCREAMING_SNAKE_CASE__       )			,				5_12       ):
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						bit_string[pos : pos + 5_12]
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						[]
														for i in range(0			,				5_12			,				32       ):
																					block_words.append(int(to_little_endian(block[i : i + 32]       )			,				2       )       )
														yield block_words




def _a (  SCREAMING_SNAKE_CASE__      :  int       )	->    int:

							'''simple docstring'''






							if i < 0:
														raise ValueError("Input must be non-negative"       )

							SCREAMING_SNAKE_CASE__       :      List[Any]     =						format(SCREAMING_SNAKE_CASE__			,				"032b"       )
							SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						""
							for c in i_str:
														new_str += "1" if c == "0" else "0"
							return int(SCREAMING_SNAKE_CASE__			,				2       )




def _a (  SCREAMING_SNAKE_CASE__      :  int			,				SCREAMING_SNAKE_CASE__      :  int       )	->    int:

							'''simple docstring'''






							return (a + b) % 2**32




def _a (  SCREAMING_SNAKE_CASE__      :  int			,				SCREAMING_SNAKE_CASE__      :  int       )	->    int:

							'''simple docstring'''






							if i < 0:
														raise ValueError("Input must be non-negative"       )
							if shift < 0:
														raise ValueError("Shift must be non-negative"       )
							return ((i << shift) ^ (i >> (32 - shift))) % 2**32




def _a (  SCREAMING_SNAKE_CASE__      :  bytes       )	->    bytes:

							'''simple docstring'''






							SCREAMING_SNAKE_CASE__       :      Dict     =						preprocess(SCREAMING_SNAKE_CASE__       )

							SCREAMING_SNAKE_CASE__       :      str     =						[int(2**32 * abs(sin(i + 1       )       )       ) for i in range(64       )]

							# Starting states
							SCREAMING_SNAKE_CASE__       :      List[str]     =						0x67452301
							SCREAMING_SNAKE_CASE__       :      Optional[int]     =						0xEFCDAB89
							SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						0x98BADCFE
							SCREAMING_SNAKE_CASE__       :      Optional[int]     =						0x10325476

							SCREAMING_SNAKE_CASE__       :      Tuple     =						[
							    7,
							    12,
							    17,
							    22,
							    7,
							    12,
							    17,
							    22,
							    7,
							    12,
							    17,
							    22,
							    7,
							    12,
							    17,
							    22,
							    5,
							    9,
							    14,
							    20,
							    5,
							    9,
							    14,
							    20,
							    5,
							    9,
							    14,
							    20,
							    5,
							    9,
							    14,
							    20,
							    4,
							    11,
							    16,
							    23,
							    4,
							    11,
							    16,
							    23,
							    4,
							    11,
							    16,
							    23,
							    4,
							    11,
							    16,
							    23,
							    6,
							    10,
							    15,
							    21,
							    6,
							    10,
							    15,
							    21,
							    6,
							    10,
							    15,
							    21,
							    6,
							    10,
							    15,
							    21,
							]

							# Process bit string in chunks, each with 16 32-char words
							for block_words in get_block_words(SCREAMING_SNAKE_CASE__       ):
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						aa
														SCREAMING_SNAKE_CASE__       :      str     =						ba
														SCREAMING_SNAKE_CASE__       :      int     =						ca
														SCREAMING_SNAKE_CASE__       :      Any     =						da

														# Hash current chunk
														for i in range(64       ):
																					if i <= 15:
																												# f = (b & c) | (not_32(b) & d)     # Alternate definition for f
																												SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						d ^ (b & (c ^ d))
																												SCREAMING_SNAKE_CASE__       :      int     =						i
																					elif i <= 31:
																												# f = (d & b) | (not_32(d) & c)     # Alternate definition for f
																												SCREAMING_SNAKE_CASE__       :      Tuple     =						c ^ (d & (b ^ c))
																												SCREAMING_SNAKE_CASE__       :      List[str]     =						(5 * i + 1) % 16
																					elif i <= 47:
																												SCREAMING_SNAKE_CASE__       :      str     =						b ^ c ^ d
																												SCREAMING_SNAKE_CASE__       :      List[str]     =						(3 * i + 5) % 16
																					else:
																												SCREAMING_SNAKE_CASE__       :      Any     =						c ^ (b | not_aa(SCREAMING_SNAKE_CASE__       ))
																												SCREAMING_SNAKE_CASE__       :      Optional[int]     =						(7 * i) % 16
																					SCREAMING_SNAKE_CASE__       :      Dict     =						(f + a + added_consts[i] + block_words[g]) % 2**32
																					SCREAMING_SNAKE_CASE__       :      Tuple     =						d
																					SCREAMING_SNAKE_CASE__       :      Dict     =						c
																					SCREAMING_SNAKE_CASE__       :      int     =						b
																					SCREAMING_SNAKE_CASE__       :      Any     =						sum_aa(SCREAMING_SNAKE_CASE__			,				left_rotate_aa(SCREAMING_SNAKE_CASE__			,				shift_amounts[i]       )       )

														# Add hashed chunk to running total
														SCREAMING_SNAKE_CASE__       :      int     =						sum_aa(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       )
														SCREAMING_SNAKE_CASE__       :      List[str]     =						sum_aa(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       )
														SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						sum_aa(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       )
														SCREAMING_SNAKE_CASE__       :      Dict     =						sum_aa(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       )

							SCREAMING_SNAKE_CASE__       :      List[str]     =						reformat_hex(SCREAMING_SNAKE_CASE__       ) + reformat_hex(SCREAMING_SNAKE_CASE__       ) + reformat_hex(SCREAMING_SNAKE_CASE__       ) + reformat_hex(SCREAMING_SNAKE_CASE__       )
							return digest


if __name__ == "__main__":
		import doctest

		doctest.testmod()













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




def _a (  SCREAMING_SNAKE_CASE__      :  str			,				SCREAMING_SNAKE_CASE__      :  complex			,				SCREAMING_SNAKE_CASE__      :  str = "x"			,				SCREAMING_SNAKE_CASE__      :  float = 10**-10			,				SCREAMING_SNAKE_CASE__      :  int = 1			,				)	->    complex:

							'''simple docstring'''






							SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						symbols(SCREAMING_SNAKE_CASE__       )
							SCREAMING_SNAKE_CASE__       :      str     =						lambdify(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       )
							SCREAMING_SNAKE_CASE__       :      int     =						lambdify(SCREAMING_SNAKE_CASE__			,				diff(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       )       )

							SCREAMING_SNAKE_CASE__       :      Any     =						starting_point

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

														SCREAMING_SNAKE_CASE__       :      Optional[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)}")






