Esempio n. 1
0
def integrate_like_mielens(function, bounds):
    pts, wts = mielensfunctions.gauss_legendre_pts_wts(bounds[0], bounds[1])
    return (function(pts) * wts).sum()
Esempio n. 2
0
 def test_guass_legendre_pts_wts_n10_gives_correct_value(self):
     p10, w10 = mielensfunctions.gauss_legendre_pts_wts(0, 1, npts=10)
     quad_10 = np.sum(np.cos(p10) * w10)
     truth = np.sin(1) - np.sin(0)
     self.assertTrue(np.isclose(quad_10, truth, **TOLS))
Esempio n. 3
0
 def test_guass_legendre_pts_wts_ndefault(self):
     p100, w100 = mielensfunctions.gauss_legendre_pts_wts(0, 1)
     quad_100 = np.sum(np.cos(p100) * w100)
     truth = np.sin(1) - np.sin(0)
     self.assertTrue(np.isclose(quad_100, truth, **TOLS))
Esempio n. 4
0
 def test_guass_legendre_pts_wts_n10_uses_10_points(self):
     npts = 10
     p10, w10 = mielensfunctions.gauss_legendre_pts_wts(0, 1, npts=npts)
     self.assertEqual(p10.size, npts)
     self.assertEqual(w10.size, npts)