




"""simple docstring"""




from __future__ import annotations







def       __UpperCAmelCase      (				__UpperCamelCase					,							__UpperCamelCase					,							__UpperCamelCase					):
			assert (
			    c % greatest_common_divisor(__UpperCamelCase					,							__UpperCamelCase					) == 0
			)  # greatest_common_divisor(a,b) function implemented below
			((__lowercase)	,(__lowercase)	,(__lowercase))	:       Optional[int]				=   extended_gcd(__UpperCamelCase					,							__UpperCamelCase					)  # extended_gcd(a,b) function implemented below
			__lowercase	:       Tuple				=   c / d
			return (r * x, r * y)







def       __UpperCAmelCase      (				__UpperCamelCase					,							__UpperCamelCase					,							__UpperCamelCase					,							__UpperCamelCase = 2					):
			((__lowercase)	,(__lowercase))	:       Any				=   diophantine(__UpperCamelCase					,							__UpperCamelCase					,							__UpperCamelCase					)  # Initial value
			__lowercase	:       Union[str, Any]				=   greatest_common_divisor(__UpperCamelCase					,							__UpperCamelCase					)
			__lowercase	:       Any				=   a // d
			__lowercase	:       int				=   b // d

			for i in range(__UpperCamelCase					):
						__lowercase	:       Any				=   xa + i * q
						__lowercase	:       Union[str, Any]				=   ya - i * p
						print(__UpperCamelCase					,							__UpperCamelCase					)







def       __UpperCAmelCase      (				__UpperCamelCase					,							__UpperCamelCase					):
			if a < b:
						__lowercase	,__lowercase	:       Dict				=   b, a

			while a % b != 0:
						__lowercase	,__lowercase	:       int				=   b, a % b

			return b







def       __UpperCAmelCase      (				__UpperCamelCase					,							__UpperCamelCase					):
			assert a >= 0 and b >= 0

			if b == 0:
						__lowercase	,__lowercase	,__lowercase	:       Union[str, Any]				=   a, 1, 0
			else:
						((__lowercase)	,(__lowercase)	,(__lowercase))	:       Optional[int]				=   extended_gcd(__UpperCamelCase					,							a % b					)
						__lowercase	:       Any				=   q
						__lowercase	:       int				=   p - q * (a // b)

			assert a % d == 0 and b % d == 0
			assert d == a * x + b * y

			return (d, x, y)


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

			testmod(name='diophantine', verbose=True)
			testmod(name='diophantine_all_soln', verbose=True)
			testmod(name='extended_gcd', verbose=True)
			testmod(name='greatest_common_divisor', verbose=True)









"""simple docstring"""




from collections.abc import Callable

a_            =   Callable[[float], float]  # type alias for a real -> real function







def       __UpperCAmelCase      (				__UpperCamelCase					,							__UpperCamelCase					,							__UpperCamelCase					,							):
			__lowercase	:       str				=   float(__UpperCamelCase					)
			while True:
						try:
									__lowercase	:       Dict				=   prev_guess - function(__UpperCamelCase					) / derivative(__UpperCamelCase					)
						except ZeroDivisionError:
									raise ZeroDivisionError('''Could not find root'''					) from None
						if abs(prev_guess - next_guess					) < 10**-5:
									return next_guess
						__lowercase	:       List[Any]				=   next_guess







def       __UpperCAmelCase      (				__UpperCamelCase					):
			return (x**3) - (2 * x) - 5







def       __UpperCAmelCase      (				__UpperCamelCase					):
			return 3 * (x**2) - 2


if __name__ == "__main__":
			print(newton(f, fa, 3))



