title: Creating a Romberg Integration Function in Python
body: <p>I have a python function for Romberg Integration as follows:</p>
  <pre><code>def romberg(f,a,b,n):
       RArray = numpy.zeros(shape=(n,n))
       for i in range(0,n):
            RArray[i,0]=trapezoidRule(f,a,b,i+1)
       for k in range(1,n):
            for j in range(1,k):
                 RArray[k,j]=RArray[k,j-i]+((RArray[k,j-1]-RArray[k-1,j-1])/(4**(j-1)-1))
       return RArray
  </code></pre>
  <p>where trapezoidRule is the function</p>
  <pre><code>def trapezoidRule(f,a,b,n):
       h=float((b-a)/n)
       ans=(f(a)/2)+(f(b)/2)
       for i in range(1,n):
            ans+=f(a+(i*h))
       ans=ans*h
       return ans
  </code></pre>
  <p>the parameters I am sending in are:</p>
  <pre><code>f = lambda x: (3/(1+x**5))
  a=0
  b=2
  n=4
  </code></pre>
  <p>but I'm getting a RuntimeWarning and not getting the RArray that I want. Can someone help me figure out what the problem is? (I'm pretty sure my ranges are wrong in my romberg function but anyway I adjust them I still get an error or a warning)</p>