Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 def test_log(self):
     Q, err = quadgr(np.log, 0, 1)
     assert_array_almost_equal(Q, -1)
     self.assert_(err < 1e-5)
Example #5
0
 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)
Example #6
0
    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)
Example #7
0
 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)
Example #8
0
 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)
Example #9
0
 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)
Example #10
0
 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)
Example #11
0
 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)
Example #12
0
 def test_log(self):
     Q, err = quadgr(np.log, 0, 1)
     assert_array_almost_equal(Q, -1)
     self.assert_(err < 1e-5)
Example #13
0
 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)
Example #14
0
    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)