code: def newton_raphson_sparse(f, guess, dfdx, x_tol=1e-10, lim_iter=100):
      
  
      converged = False
      n_iter = 0
      F = f(guess)
      diff = norm(F,np.Inf)
  
      logger.debug("Error at iteration %d: %f", n_iter, diff)
  
      while diff > x_tol and n_iter < lim_iter:
  
          n_iter +=1
  
          guess = guess - spsolve(dfdx(guess),F)
  
          F = f(guess)
          diff = norm(F,np.Inf)
  
          logger.debug("Error at iteration %d: %f", n_iter, diff)
  
      if diff > x_tol:
          logger.warning("Warning, we didn't reach the required tolerance within %d iterations, error is at %f. See the section \"Troubleshooting\" in the documentation for tips to fix this. ", n_iter, diff)
      elif not np.isnan(diff):
          converged = True
  
      return guess, n_iter, diff, converged
docs: Solve f(x) = 0 with initial guess for x and dfdx(x). dfdx(x) should
      return a sparse Jacobian.  Terminate if error on norm of f(x) is <
      x_tol or there were more than lim_iter iterations.