Пример #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)
Пример #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)
Пример #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)
Пример #4
0
 def test_log(self):
     Q, err = quadgr(np.log, 0, 1)
     assert_array_almost_equal(Q, -1)
     self.assert_(err < 1e-5)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #12
0
 def test_log(self):
     Q, err = quadgr(np.log, 0, 1)
     assert_array_almost_equal(Q, -1)
     self.assert_(err < 1e-5)
Пример #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)
Пример #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)