def test_integrand4(self): tol = 1e-10 Q, err = quadgr(lambda x: 1./np.sqrt(1-x**2), -1, 1, tol) assert_array_almost_equal(Q, np.pi) self.assert_(err < tol)
def test_integral3(self): tol = 1e-12 Q, err = quadgr(lambda x: np.sqrt(4-x**2), 0, 2, tol) assert_array_almost_equal(Q, np.pi) self.assert_(err < tol)
def test_integral4(self): Q, err = quadgr(lambda x: 1./x**0.75, 0, 1) assert_array_almost_equal(Q, 4) self.assert_(err < 1.0e-12)
def test_log(self): Q, err = quadgr(np.log, 0, 1) assert_array_almost_equal(Q, -1) self.assert_(err < 1e-5)
def test_exp(self): Q, err = quadgr(np.exp, 0, 9999*1j*np.pi) assert_array_almost_equal(Q, -2.0000000000122662) self.assert_(err < 1.0e-8)
def test_integrand5(self): tol = 1e-9 Q, err = quadgr(lambda x: np.exp(-x**2), -np.inf, np.inf, tol) assert_array_almost_equal(Q, np.sqrt(np.pi)) self.assert_(err < tol)
def test_integrand6(self): tol = 1e-9 Q, err = quadgr(lambda x: np.cos(x) * np.exp(-x), 0, np.inf, tol) assert_array_almost_equal(Q, 0.5) self.assert_(err < tol)
def test_integrand6(self): tol = 1e-9 Q, err = quadgr(lambda x: np.cos(x)*np.exp(-x), 0, np.inf, tol) assert_array_almost_equal(Q, 0.5) self.assert_(err < tol)