input: Write a function to implement Newton-Raphson method for finding roots of an equation.
  assert abs(newtonRaphson(3) - (-1.0)) < 0.0001
  assert abs(newtonRaphson(-2) - (-1.0)) < 0.0001
  assert abs(newtonRaphson(0) - (-1.0)) < 0.0001
output: def newtonRaphson(x0, tol=0.0001, max_iter=1000):
      def f(x):
          return x**3 + 2*x**2 + x + 2
  
      def df(x):
          return 3*x**2 + 4*x + 1
      
      x = x0
      for _ in range(max_iter):
          fx = f(x)
          dfx = df(x)
          if abs(fx) < tol:
              return x
          if dfx == 0:
              raise ValueError("Derivative is zero. No solution found.")
          x = x - fx / dfx
      raise ValueError("Max iterations exceeded. No solution found.")