



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





def 					__snake_case     (      _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase = "x"       ,			_UpperCAmelCase = 10**-10       ,			_UpperCAmelCase = 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 					__snake_case     (      _UpperCAmelCase    ):
    if not isinstance(_UpperCAmelCase       ,			_UpperCAmelCase    ):
        raise TypeError('''Input value must be an \'int\' type'''    )

    __a							=    0
    while number:
        position += 1
        number >>= 1

    return position


if __name__ == "__main__":
 import doctest

 doctest.testmod()





