




"""simple docstring"""




def       __UpperCAmelCase      (				__UpperCamelCase					):
			__lowercase	:       str				=   1
			__lowercase	:       List[Any]				=   0
			__lowercase	:       Union[str, Any]				=   1
			__lowercase	:       Optional[int]				=   1
			__lowercase	:       Dict				=   3
			__lowercase	:       List[str]				=   3
			__lowercase	:       Dict				=   limit
			__lowercase	:       Optional[int]				=   0

			__lowercase	:       List[Any]				=   ''''''
			while counter != decimal + 1:
						if 4 * q + r - t < n * t:
									result += str(__UpperCamelCase					)
									if counter == 0:
												result += "."

									if decimal == counter:
												break

									counter += 1
									__lowercase	:       List[Any]				=   10 * (r - n * t)
									__lowercase	:       List[str]				=   ((10 * (3 * q + r)) // t) - 10 * n
									q *= 10
									__lowercase	:       Union[str, Any]				=   nr
						else:
									__lowercase	:       List[str]				=   (2 * q + r) * l
									__lowercase	:       Optional[int]				=   (q * (7 * k) + 2 + (r * l)) // (t * l)
									q *= k
									t *= l
									l += 2
									k += 1
									__lowercase	:       Optional[Any]				=   nn
									__lowercase	:       Dict				=   nr
			return result







def       __UpperCAmelCase      (				):
			print(f"""{calculate_pi(50					) = }"""					)
			import doctest

			doctest.testmod()


if __name__ == "__main__":
			main()









"""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))



