from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403
def 							lowerCAmelCase(     __lowerCamelCase				,    __lowerCamelCase				,    __lowerCamelCase = "x"				,    __lowerCamelCase = 10**-10				,    __lowerCamelCase = 1				,    ):
					__a		 =       symbols(UpperCamelCase__						)
					__a		 =       lambdify(UpperCamelCase__				,    UpperCamelCase__						)
					__a		 =       lambdify(UpperCamelCase__				,    diff(UpperCamelCase__				,    UpperCamelCase__						)						)

					__a		 =       starting_point

					while True:
										if diff_function(UpperCamelCase__						) != 0:
															__a		 =       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

										__a		 =       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_0_5)}''',
	)

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





def 							lowerCAmelCase(     __lowerCamelCase						):
					if not all(char in '01' for char in bin_string						):
										raise ValueError('Non-binary value was passed to the function'						)
					if not bin_string:
										raise ValueError('Empty string was passed to the function'						)
					__a		 =       ''
					while len(__lowerCamelCase						) % 3 != 0:
										__a		 =       '0' + bin_string
					__a		 =       [
					    bin_string[index : index + 3]
					    for index in range(len(__lowerCamelCase						)						)
					    if index % 3 == 0
					]
					for bin_group in bin_string_in_3_list:
										__a		 =       0
										for index, val in enumerate(__lowerCamelCase						):
															oct_val += int(2 ** (2 - index) * int(__lowerCamelCase						)						)
										oct_string += str(__lowerCamelCase						)
					return oct_string


if __name__ == "__main__":
	from doctest import testmod

	testmod()




