




'''simple docstring'''





class 			_snake_case		:




			def __init__( self    ,							a__							)    ->    None:

										'''simple docstring'''




										snake_case_      =				len(a__							)
										snake_case_      =				[0] * len_array

										if len_array > 0:
																	snake_case_      =				array[0]

										for i in range(1    ,							a__							):
																	snake_case_      =				self.prefix_sum[i - 1] + array[i]




			def        lowerCAmelCase__    ( self    ,							a__    ,							a__							)    ->    int:

										'''simple docstring'''




										if start == 0:
																	return self.prefix_sum[end]

										return self.prefix_sum[end] - self.prefix_sum[start - 1]




			def        lowerCAmelCase__    ( self    ,							a__							)    ->    bool:

										'''simple docstring'''




										snake_case_      =				{0}
										for sum_item in self.prefix_sum:
																	if sum_item - target_sum in sums:
																								return True

																	sums.add(a__							)

										return False


if __name__ == "__main__":
		import doctest

		doctest.testmod()










'''simple docstring'''





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


def 					UpperCamelCase_(     snake_case							:	str							,    snake_case							:	complex							,    snake_case							:	str = "x"							,    snake_case							:	float = 1_0**-1_0							,    snake_case							:	int = 1							,    ):

							'''simple docstring'''






							snake_case_      =				symbols(snake_case					)
							snake_case_      =				lambdify(snake_case							,    snake_case					)
							snake_case_      =				lambdify(snake_case							,    diff(snake_case							,    snake_case					)					)

							snake_case_      =				starting_point

							while True:
														if diff_function(snake_case					) != 0:
																					snake_case_      =				prev_guess - multiplicity * func(snake_case					) / diff_function(
																					    snake_case					)
														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

														snake_case_      =				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)}")




