code: def tridi_inverse_iteration(d, e, w, x0=None, rtol=1e-8):
      
      eig_diag = d - w
      if x0 is None:
          x0 = np.random.randn(len(d))
      x_prev = np.zeros_like(x0)
      norm_x = np.linalg.norm(x0)
      # the eigenvector is unique up to sign change, so iterate
      # until || |x^(n)| - |x^(n-1)| ||^2 < rtol
      x0 /= norm_x
      while np.linalg.norm(np.abs(x0) - np.abs(x_prev)) > rtol:
          x_prev = x0.copy()
          tridisolve(eig_diag, e, x0)
          norm_x = np.linalg.norm(x0)
          x0 /= norm_x
      return x0
docs: Perform an inverse iteration to find the eigenvector corresponding
      to the given eigenvalue in a symmetric tridiagonal system.
  
      Parameters
      ----------
  
      d : ndarray
        main diagonal of the tridiagonal system
      e : ndarray
        offdiagonal stored in e[:-1]
      w : float
        eigenvalue of the eigenvector
      x0 : ndarray
        initial point to start the iteration
      rtol : float
        tolerance for the norm of the difference of iterates
  
      Returns
      -------
  
      e : ndarray
        The converged eigenvector