Beispiel #1
0
    def test_gauss_legendre(self):
        val, _err = gaussq(exp, 0, 1)
        self.assertAlmostEqual(val, exp(1)-exp(0))

        a, b, y = [0, 0], [1, 1], np.array([1., 2.])
        val, _err = gaussq(lambda x, y: x * y, a, b, args=(y, ))
        assert_array_almost_equal(val, 0.5*y)
    def test_gauss_legendre(self):
        val, _err = gaussq(exp, 0, 1)
        self.assertAlmostEqual(val, exp(1) - exp(0))

        a, b, y = [0, 0], [1, 1], np.array([1., 2.])
        val, _err = gaussq(lambda x, y: x * y, a, b, args=(y, ))
        assert_array_almost_equal(val, 0.5 * y)
Beispiel #3
0
 def test_gauss_laguerre(self):
     val, _err = gaussq(lambda x: x, 0, Inf, wfun=3, alpha=1)
     assert_array_almost_equal(val, 2)
Beispiel #4
0
 def test_gauss_wfun8(self):
     f = lambda x: x
     val, _err = gaussq(f, 0, 1, wfun=8)
     self.assertAlmostEqual(val, 1.33333333)
Beispiel #5
0
 def test_gauss_wfun5_6(self):
     f = lambda x: x
     for i in [5, 6]:
         val, _err = gaussq(f, -1, 1, wfun=i)
         self.assertAlmostEqual(val, 0)
Beispiel #6
0
 def test_gauss_laguerre(self):
     f = lambda x: x
     val, _err = gaussq(f, 0, Inf, wfun=3, alpha=1)
     self.assertAlmostEqual(val, 2)
 def test_gauss_wfun8(self):
     f = lambda x: x
     val, _err = gaussq(f, 0, 1, wfun=8)
     self.assertAlmostEqual(val, 1.33333333)
 def test_gauss_wfun5_6(self):
     f = lambda x: x
     for i in [5, 6]:
         val, _err = gaussq(f, -1, 1, wfun=i)
         self.assertAlmostEqual(val, 0)
Beispiel #9
0
 def test_gauss_laguerre(self):
     val, _err = gaussq(lambda x: x, 0, Inf, wfun=3, alpha=1)
     assert_array_almost_equal(val, 2)
Beispiel #10
0
 def test_gauss_hermite(self):
     val, _err = gaussq(lambda x: x, -Inf, Inf, wfun=2)
     assert_array_almost_equal(val, 0)
Beispiel #11
0
 def test_gauss_wfun9(self):
     val, _err = gaussq(lambda x: x, 0, 1, wfun=9)
     assert_array_almost_equal(val, 0.26666667)
Beispiel #12
0
 def test_gauss_wfun8(self):
     val, _err = gaussq(lambda x: x, 0, 1, wfun=8)
     assert_array_almost_equal(val, 1.33333333)
Beispiel #13
0
 def test_gauss_wfun7(self):
     val, _err = gaussq(lambda x: x, 0, 1, wfun=7)
     assert_array_almost_equal(val, 1.17809725)
Beispiel #14
0
 def test_gauss_wfun5_6(self):
     for i in [5, 6]:
         val, _err = gaussq(lambda x: x, -1, 1, wfun=i)
         assert_array_almost_equal(val, 0)
Beispiel #15
0
 def test_gauss_jacobi(self):
     val, _err = gaussq(lambda x: x, -1, 1, wfun=4, alpha=-0.5, beta=-0.5)
     assert_array_almost_equal(val, 0)
 def test_gauss_laguerre(self):
     f = lambda x: x
     val, _err = gaussq(f, 0, Inf, wfun=3, alpha=1)
     self.assertAlmostEqual(val, 2)
 def test_gauss_jacobi(self):
     f = lambda x: x
     val, _err = gaussq(f, -1, 1, wfun=4, alpha=-0.5, beta=-0.5)
     self.assertAlmostEqual(val, 0)
Beispiel #18
0
 def test_gauss_jacobi(self):
     val, _err = gaussq(lambda x: x, -1, 1, wfun=4, alpha=-0.5, beta=-0.5)
     assert_array_almost_equal(val, 0)
 def test_gauss_wfun7(self):
     f = lambda x: x
     val, _err = gaussq(f, 0, 1, wfun=7)
     self.assertAlmostEqual(val, 1.17809725)
Beispiel #20
0
 def test_gauss_wfun5_6(self):
     for i in [5, 6]:
         val, _err = gaussq(lambda x: x, -1, 1, wfun=i)
         assert_array_almost_equal(val, 0)
 def test_gauss_wfun9(self):
     f = lambda x: x
     val, _err = gaussq(f, 0, 1, wfun=9)
     self.assertAlmostEqual(val, 0.26666667)
Beispiel #22
0
 def test_gauss_wfun7(self):
     val, _err = gaussq(lambda x: x, 0, 1, wfun=7)
     assert_array_almost_equal(val, 1.17809725)
Beispiel #23
0
 def test_gauss_hermite(self):
     f = lambda x: x
     val, _err = gaussq(f, -Inf, Inf, wfun=2)
     self.assertAlmostEqual(val, 0)
Beispiel #24
0
 def test_gauss_wfun8(self):
     val, _err = gaussq(lambda x: x, 0, 1, wfun=8)
     assert_array_almost_equal(val, 1.33333333)
Beispiel #25
0
 def test_gauss_jacobi(self):
     f = lambda x: x
     val, _err = gaussq(f, -1, 1, wfun=4, alpha=-0.5, beta=-0.5)
     self.assertAlmostEqual(val, 0)
Beispiel #26
0
 def test_gauss_wfun9(self):
     val, _err = gaussq(lambda x: x, 0, 1, wfun=9)
     assert_array_almost_equal(val, 0.26666667)
Beispiel #27
0
 def test_gauss_wfun7(self):
     f = lambda x: x
     val, _err = gaussq(f, 0, 1, wfun=7)
     self.assertAlmostEqual(val, 1.17809725)
 def test_gauss_hermite(self):
     f = lambda x: x
     val, _err = gaussq(f, -Inf, Inf, wfun=2)
     self.assertAlmostEqual(val, 0)
Beispiel #29
0
 def test_gauss_wfun9(self):
     f = lambda x: x
     val, _err = gaussq(f, 0, 1, wfun=9)
     self.assertAlmostEqual(val, 0.26666667)
Beispiel #30
0
 def test_gauss_hermite(self):
     val, _err = gaussq(lambda x: x, -Inf, Inf, wfun=2)
     assert_array_almost_equal(val, 0)