コード例 #1
0
def test_l_roots():
    weightf = orth.laguerre(5).weight_func
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0., np.inf, 5)
    verify_gauss_quad(orth.l_roots,
                      orth.eval_laguerre,
                      weightf,
                      0.,
                      np.inf,
                      25,
                      atol=1e-13)
    verify_gauss_quad(orth.l_roots,
                      orth.eval_laguerre,
                      weightf,
                      0.,
                      np.inf,
                      100,
                      atol=1e-12)

    x, w = orth.l_roots(5, False)
    y, v, m = orth.l_roots(5, True)
    assert_allclose(x, y, 1e-14, 1e-14)
    assert_allclose(w, v, 1e-14, 1e-14)

    muI, muI_err = integrate.quad(weightf, 0, np.inf)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, orth.l_roots, 0)
    assert_raises(ValueError, orth.l_roots, 3.3)
コード例 #2
0
ファイル: test_orthogonal.py プロジェクト: ESSS/scipy
def test_l_roots():
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, 5)
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, 25, atol=1e-13)
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, 100, atol=1e-12)

    x, w = orth.l_roots(5, False)
    y, v, m = orth.l_roots(5, True)
    assert_allclose(x, y, 1e-14, 1e-14)
    assert_allclose(w, v, 1e-14, 1e-14)

    assert_raises(ValueError, orth.l_roots, 0)
    assert_raises(ValueError, orth.l_roots, 3.3)
コード例 #3
0
ファイル: test_orthogonal.py プロジェクト: ChadFulton/scipy
def test_l_roots():
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, 5)
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, 25, atol=1e-13)
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, 100, atol=1e-12)

    x, w = orth.l_roots(5, False)
    y, v, m = orth.l_roots(5, True)
    assert_allclose(x, y, 1e-14, 1e-14)
    assert_allclose(w, v, 1e-14, 1e-14)

    assert_raises(ValueError, orth.l_roots, 0)
    assert_raises(ValueError, orth.l_roots, 3.3)
コード例 #4
0
ファイル: test_orthogonal.py プロジェクト: GiladAmar/scipy
def test_l_roots():
    weightf = orth.laguerre(5).weight_func
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0.0, np.inf, 5)
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0.0, np.inf, 25, atol=1e-13)
    verify_gauss_quad(orth.l_roots, orth.eval_laguerre, weightf, 0.0, np.inf, 100, atol=1e-12)

    x, w = orth.l_roots(5, False)
    y, v, m = orth.l_roots(5, True)
    assert_allclose(x, y, 1e-14, 1e-14)
    assert_allclose(w, v, 1e-14, 1e-14)

    muI, muI_err = integrate.quad(weightf, 0, np.inf)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, orth.l_roots, 0)
    assert_raises(ValueError, orth.l_roots, 3.3)
コード例 #5
0
c = 299792458
M = 10**6
beta = 1.0 / (20.0 * M)
hbar = 6.58211928 * (10**(-16))  # eV

########################################
########################################
####### Problem 2 - first Part #########
########################################
########################################

xGridCount = 50

constant = 8.0 * pi * ((1.0 / beta)**3) / ((2 * pi * c * hbar)**3)

[laguerre_roots, laguerre_weights] = scipy_orth.l_roots(xGridCount, 0)

IntegralSum = 0.0

for i in range(0, xGridCount):
    IntegralSum = IntegralSum + laguerre_weights[i] * (
        laguerre_roots[i]**2 * exp(laguerre_roots[i]) /
        (exp(laguerre_roots[i]) + 1.0))
else:
    print "The Integral is (gaussian-laguerre method) : ", IntegralSum

##################################################
# Checking the integral answer by another method #
##################################################

xGridCount = 10000
コード例 #6
0
ファイル: In-Class-2.py プロジェクト: afarahi/Ay190
c = 299792458
M = 10**6
beta = 1.0/(20.0*M)
hbar = 6.58211928*(10**(-16)) # eV

########################################
########################################
####### Problem 2 - first Part #########
########################################
########################################

xGridCount = 50;

constant = 8.0*pi*((1.0/beta)**3) / ((2*pi*c*hbar)**3)

[laguerre_roots,laguerre_weights] = scipy_orth.l_roots(xGridCount,0)

IntegralSum = 0.0;

for i in range(0, xGridCount):
   IntegralSum = IntegralSum + laguerre_weights[i]*(laguerre_roots[i]**2 * exp(laguerre_roots[i]) / (exp(laguerre_roots[i]) + 1.0));
else:
   print "The Integral is (gaussian-laguerre method) : ", IntegralSum

##################################################
# Checking the integral answer by another method #
##################################################

xGridCount = 10000;

IntegralSum = 0.0;