3
from numpy import cos, sin, pi
4
from numpy.testing import *
7
from scipy.integrate import quadrature, romberg, romb
10
class test_quadrature(ScipyTestCase):
11
def quad(self, x, a, b, args):
12
raise NotImplementedError
14
def check_quadrature(self):
15
# Typical function with two extra arguments:
16
def myfunc(x,n,z): # Bessel function integrand
17
return cos(n*x-z*sin(x))/pi
18
val, err = quadrature(myfunc,0,pi,(2,1.8))
19
table_val = 0.30614353532540296487
20
assert_almost_equal(val, table_val, decimal=7)
22
def check_romberg(self):
23
# Typical function with two extra arguments:
24
def myfunc(x, n, z): # Bessel function integrand
25
return cos(n*x-z*sin(x))/pi
26
val = romberg(myfunc,0,pi, args=(2, 1.8))
27
table_val = 0.30614353532540296487
28
assert_almost_equal(val, table_val, decimal=7)
31
assert_equal(romb(numpy.arange(17)),128)
33
if __name__ == "__main__":