



'''simple docstring'''

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






def 				a  (     UpperCamelCase_    :    str      ,					UpperCamelCase_    :    complex      ,					UpperCamelCase_    :    str = "x"      ,					UpperCamelCase_    :    float = 10**-10      ,					UpperCamelCase_    :    int = 1      ,					)       ->	complex:
		snake_case__	     =symbols(UpperCamelCase_			)
		snake_case__	     =lambdify(UpperCamelCase_      ,					UpperCamelCase_			)
		snake_case__	     =lambdify(UpperCamelCase_      ,					diff(UpperCamelCase_      ,					UpperCamelCase_			)			)

		snake_case__	     =starting_point

		while True:
				if diff_function(UpperCamelCase_			) != 0:
						snake_case__	     =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

				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', 1_0, precision=0.005)}""",
			)

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









'''simple docstring'''

from __future__ import annotations

SCREAMING_SNAKE_CASE__     :						List[Any]	=  1.6021e-19  # units = C






def 				a  (     UpperCamelCase_    :    float      ,					UpperCamelCase_    :    float      ,					UpperCamelCase_    :    float      ,					)       ->	tuple[str, float]:
		if (conductivity, electron_conc, mobility).count(0			) != 1:
				raise ValueError('You cannot supply more or less than 2 values'			)
		elif conductivity < 0:
				raise ValueError('Conductivity cannot be negative'			)
		elif electron_conc < 0:
				raise ValueError('Electron concentration cannot be negative'			)
		elif mobility < 0:
				raise ValueError('mobility cannot be negative'			)
		elif conductivity == 0:
				return (
				    "conductivity",
				    mobility * electron_conc * ELECTRON_CHARGE,
				)
		elif electron_conc == 0:
				return (
				    "electron_conc",
				    conductivity / (mobility * ELECTRON_CHARGE),
				)
		else:
				return (
				    "mobility",
				    conductivity / (electron_conc * ELECTRON_CHARGE),
				)


if __name__ == "__main__":
			import doctest

			doctest.testmod()




