





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






def 							_lowerCAmelCase (  _a   :					str					,   _a   :					complex					,   _a   :					str = "x"					,   _a   :					float = 10**-10					,   _a   :					int = 1					,   )	->			complex:
     lowerCAmelCase_					:       Dict    =		symbols(_a			)
     lowerCAmelCase_					:       Optional[int]    =		lambdify(_a					,   _a			)
     lowerCAmelCase_					:       List[str]    =		lambdify(_a					,   diff(_a					,   _a			)			)

     lowerCAmelCase_					:       Tuple    =		starting_point

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

          lowerCAmelCase_					:       List[str]    =		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_05)}""",
      )

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







from collections.abc import Sequence






def 							_lowerCAmelCase (  _a   :					Sequence[float]					,   _a   :					bool = False			)	->			float:
     if not arr:
          return 0

     lowerCAmelCase_					:       List[str]    =		0 if allow_empty_subarrays else float("""-inf"""			)
     lowerCAmelCase_					:       List[Any]    =		0.0
     for num in arr:
          lowerCAmelCase_					:       int    =		max(0 if allow_empty_subarrays else num					,   curr_sum + num			)
          lowerCAmelCase_					:       List[str]    =		max(_a					,   _a			)

     return max_sum


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

      testmod()

      UpperCAmelCase_					:   int 							=						[-2, 1, -3, 4, -1, 2, 1, -5, 4]
      print(F"""{max_subarray_sum(nums) = }""")
