title: How to avoid getting this error in the plot of a function? RuntimeWarning: invalid value encountered in true_divide
body: <p>I'm trying to plot this function, but I'm getting this error:</p>
  <pre><code>python3 Bound_state_energy
  </code></pre>
  <p>Bound_state_energy:43: RuntimeWarning: invalid value encountered in true_divide
  E = -(2<em>hbar**2/m_e</em>R<strong>2)*(Gamma1/Gamma2)</strong>(1/abs(m+phi)) - hbar<em>Omega</em>(m+phi+s/2)</p>
  <p>I know that this error has been addressed in other questions, but I couldn't find any similar situation, so I still haven't found an answer that would help men.  Here is the complete code: `</p>
  <pre><code>`import numpy as np
  from scipy.special import gamma
  #np.seterr(divide='ignore', invalid='ignore')
  import matplotlib.pyplot as plt
  from scipy.constants import pi
  
  #constantes
  hbar = 4.135667696e-15/2*pi
  m_e =  0.51099895e6
  s = -1
  R = 5e-9
  m = 0
  g = 2.0012
  phi = np.linspace(0, 1.0, 1000)
  
  # Função que define a energia em função de phi
  def energy_bound_state(phi,Omega):
      Gamma1 = gamma(1+abs(m+phi))*(1/2*g*s*phi + abs(m+phi))
      Gamma2 = gamma(1-abs(m+phi))*(1/2*g*s*phi - abs(m+phi))
      E = -(2*hbar**2/m_e*R**2)*(Gamma1/Gamma2)**(1/abs(m+phi)) - hbar*Omega*(m+phi+s/2)
      return E
  
  for Omega in (0.85e9, 0.9e9, 0.95e9, 1.0e9):
      plt.plot(phi, energy_bound_state(phi,Omega))
  plt.show()
  </code></pre>