title: Integrating a function of two variables over an array of values
body: <p>I'm currently trying to solve this integral using SciPy:</p>
  <p><a href="https://i.stack.imgur.com/59sRn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/59sRn.png" alt="Bounds of integral is a variable that is different from the variable of integration, but also variable in bounds is in the integrand." /></a></p>
  <p>I was first advised to use interpolation, which I tried but cannot figure out for some reason, but would probably be a good approach. I found <a href="https://stackoverflow.com/questions/43718128/integrate-a-function-with-each-element-of-numpy-arrays-as-limit-of-integration">this post</a> about using <code>np.vectorize</code> and I think it might still work, but I am getting an error. Here is the code that I have written thus far (also note that n and n,eq are not indices, they're just variable names):</p>
  <pre><code>import numpy as np
  from scipy import integrate 
  
  def K(x): #This is a function in the integral.
      b = 0.252
      return b*(((4/(x**3))+(3/(x**2))+1/x) + (4/(x**3) + 1/(x**2))*np.exp(-x))
  
  def Xntot_integrand(x,z): #Defining the integrand
      Xneq_x = (1+np.exp(x))**(-1) #This is the term outside the integral and squared within it.
      return Xneq_x(x)**2 * np.exp(K(z) - K(x)) * np.exp(x)
  
  Xntot_integrand = np.vectorize(Xntot_integrand)
  
  def Xntot_integrated(x,z):
      return quad(Xntot_integrand, 0, z)
  
  Xntot_integrated=np.vectorize(Xntot_integrated)
  
  T_narrow = np.linspace(1,0.01,100) #Narrow T range from 1 to 0.01 MeV
  z_narrow = Q/T_narrow
  
  final_integrated_Xneq = Xntot_integrated(z_narrow)
  </code></pre>
  <p>I am getting the error that I am missing a positional argument when I call <code>Xntot_integrated</code> (which makes sense, I think it is still in the two variables x and z).</p>
  <p>So I suppose the issue is stemming from where I use <code>quad()</code> because after it is integrated, x should go away. Any advice? Should I use tabulation/interpolation instead?</p>