

"""simple docstring"""




from __future__ import annotations

from decimal import Decimal
from math import *  # noqa: F403

from sympy import diff
def   lowerCAmelCase						(					__UpperCamelCase							,    __UpperCamelCase							,    __UpperCamelCase = 10**-10      ):
 '''simple docstring'''





 UpperCAmelCase__					:  int					   =					a
 while True:
  UpperCAmelCase__					:  List[str]					   =					Decimal(__UpperCamelCase      ) - (
      Decimal(eval(__UpperCamelCase      )      ) / Decimal(eval(str(diff(__UpperCamelCase      )      )      )      )  # noqa: S307
  )
  # This number dictates the accuracy of the answer
  if abs(eval(__UpperCamelCase      )      ) < precision:  # noqa: S307
   return float(__UpperCamelCase      )


# 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
      print(F"The root of x**2 - 5*x + 2 = 0 is {newton_raphson('x**2 - 5*x + 2', 0.4)}")
      # Find Square Root of 5
      print(F"The root of log(x) - 1 = 0 is {newton_raphson('log(x) - 1', 2)}")
      # Exponential Roots
      print(F"The root of exp(x) - 1 = 0 is {newton_raphson('exp(x) - 1', 0)}")








"""simple docstring"""




def   lowerCAmelCase						(					__UpperCamelCase      ):
 '''simple docstring'''





 UpperCAmelCase__					:  str					   =					[]
 if len(__UpperCamelCase      ) == 1:
  return [nums.copy()]
 for _ in range(len(__UpperCamelCase      )      ):
  UpperCAmelCase__					:  Tuple					   =					nums.pop(0      )
  UpperCAmelCase__					:  List[str]					   =					permute(__UpperCamelCase      )
  for perm in permutations:
   perm.append(__UpperCamelCase      )
  result.extend(__UpperCamelCase      )
  nums.append(__UpperCamelCase      )
 return result
def   lowerCAmelCase						(					__UpperCamelCase      ):
 '''simple docstring'''





 def backtrack(__UpperCamelCase      ):
  if start == len(__UpperCamelCase      ) - 1:
   output.append(nums[:]      )
  else:
   for i in range(__UpperCamelCase							,    len(__UpperCamelCase      )      ):
    UpperCAmelCase__   ,      UpperCAmelCase__					:  Union[str, Any]					   =					nums[i], nums[start]
    backtrack(start + 1      )
    UpperCAmelCase__   ,      UpperCAmelCase__					:  Union[str, Any]					   =					nums[i], nums[start]  # backtrack

 UpperCAmelCase__					:  List[str]					   =					[]
 backtrack(0      )
 return output


if __name__ == "__main__":
      import doctest

      # use res to print the data in permute2 function
      __UpperCAmelCase =				permutea([1, 2, 3])
      print(res)
      doctest.testmod()





