title: Plot an non-linear function with poles
body: <p>I am trying to plot a non-linear function with poles but I can not get the results. The code I am using is</p>
  <pre><code>H = np.diag((1, 2, 3, 4))
  g = np.array([1, 1, 1, 1])
  
  Lambda, U = np.linalg.eig(H)
  psi = lambda l: np.linalg.norm(np.dot(np.diag(1. / (np.diag(Lambda + l))) @ U, g))**2
  x = np.arange(-16.0, 4.0, 0.05)
  y = [psi(xx) for xx in x]
  plt.plot(x, y)
  plt.show()
  </code></pre>
  <p>The expected result is</p>
  <p><a href="https://i.stack.imgur.com/dcyUU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dcyUU.png" alt="enter image description here" /></a></p>
  <p>Could you please someone suggest a way to handle the poles and get the result?</p>