Exemple #1
0
def test_j_roots():
    rf = lambda a, b: lambda n, mu: orth.j_roots(n, a, b, mu)
    ef = lambda a, b: lambda n, x: orth.eval_jacobi(n, a, b, x)
    wf = lambda a, b: lambda x: (1 - x) ** a * (1 + x) ** b

    vgq = verify_gauss_quad
    vgq(rf(-0.5, -0.75), ef(-0.5, -0.75), wf(-0.5, -0.75), -1.0, 1.0, 5)
    vgq(rf(-0.5, -0.75), ef(-0.5, -0.75), wf(-0.5, -0.75), -1.0, 1.0, 25, atol=1e-12)
    vgq(rf(-0.5, -0.75), ef(-0.5, -0.75), wf(-0.5, -0.75), -1.0, 1.0, 100, atol=1e-11)

    vgq(rf(0.5, -0.5), ef(0.5, -0.5), wf(0.5, -0.5), -1.0, 1.0, 5)
    vgq(rf(0.5, -0.5), ef(0.5, -0.5), wf(0.5, -0.5), -1.0, 1.0, 25, atol=1.5e-13)
    vgq(rf(0.5, -0.5), ef(0.5, -0.5), wf(0.5, -0.5), -1.0, 1.0, 100, atol=1e-12)

    vgq(rf(1, 0.5), ef(1, 0.5), wf(1, 0.5), -1.0, 1.0, 5, atol=2e-13)
    vgq(rf(1, 0.5), ef(1, 0.5), wf(1, 0.5), -1.0, 1.0, 25, atol=2e-13)
    vgq(rf(1, 0.5), ef(1, 0.5), wf(1, 0.5), -1.0, 1.0, 100, atol=1e-12)

    vgq(rf(0.9, 2), ef(0.9, 2), wf(0.9, 2), -1.0, 1.0, 5)
    vgq(rf(0.9, 2), ef(0.9, 2), wf(0.9, 2), -1.0, 1.0, 25, atol=1e-13)
    vgq(rf(0.9, 2), ef(0.9, 2), wf(0.9, 2), -1.0, 1.0, 100, atol=2e-13)

    vgq(rf(18.24, 27.3), ef(18.24, 27.3), wf(18.24, 27.3), -1.0, 1.0, 5)
    vgq(rf(18.24, 27.3), ef(18.24, 27.3), wf(18.24, 27.3), -1.0, 1.0, 25)
    vgq(rf(18.24, 27.3), ef(18.24, 27.3), wf(18.24, 27.3), -1.0, 1.0, 100, atol=1e-13)

    vgq(rf(47.1, -0.2), ef(47.1, -0.2), wf(47.1, -0.2), -1.0, 1.0, 5, atol=1e-13)
    vgq(rf(47.1, -0.2), ef(47.1, -0.2), wf(47.1, -0.2), -1.0, 1.0, 25, atol=2e-13)
    vgq(rf(47.1, -0.2), ef(47.1, -0.2), wf(47.1, -0.2), -1.0, 1.0, 100, atol=1e-11)

    vgq(rf(2.25, 68.9), ef(2.25, 68.9), wf(2.25, 68.9), -1.0, 1.0, 5)
    vgq(rf(2.25, 68.9), ef(2.25, 68.9), wf(2.25, 68.9), -1.0, 1.0, 25, atol=1e-13)
    vgq(rf(2.25, 68.9), ef(2.25, 68.9), wf(2.25, 68.9), -1.0, 1.0, 100, atol=1e-13)

    # when alpha == beta == 0, P_n^{a,b}(x) == P_n(x)
    xj, wj = orth.j_roots(6, 0.0, 0.0)
    xl, wl = orth.p_roots(6)
    assert_allclose(xj, xl, 1e-14, 1e-14)
    assert_allclose(wj, wl, 1e-14, 1e-14)

    # when alpha == beta != 0, P_n^{a,b}(x) == C_n^{alpha+0.5}(x)
    xj, wj = orth.j_roots(6, 4.0, 4.0)
    xc, wc = orth.cg_roots(6, 4.5)
    assert_allclose(xj, xc, 1e-14, 1e-14)
    assert_allclose(wj, wc, 1e-14, 1e-14)

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

    muI, muI_err = integrate.quad(wf(2, 3), -1, 1)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, orth.j_roots, 0, 1, 1)
    assert_raises(ValueError, orth.j_roots, 3.3, 1, 1)
    assert_raises(ValueError, orth.j_roots, 3, -2, 1)
    assert_raises(ValueError, orth.j_roots, 3, 1, -2)
    assert_raises(ValueError, orth.j_roots, 3, -2, -2)
Exemple #2
0
def test_cg_roots():
    rootf = lambda a: lambda n, mu: orth.cg_roots(n, a, mu)
    evalf = lambda a: lambda n, x: orth.eval_gegenbauer(n, a, x)
    weightf = lambda a: lambda x: (1 - x**2)**(a - 0.5)

    vgq = verify_gauss_quad
    vgq(rootf(-0.25), evalf(-0.25), weightf(-0.25), -1., 1., 5)
    vgq(rootf(-0.25), evalf(-0.25), weightf(-0.25), -1., 1., 25, atol=1e-12)
    vgq(rootf(-0.25), evalf(-0.25), weightf(-0.25), -1., 1., 100, atol=1e-11)

    vgq(rootf(0.1), evalf(0.1), weightf(0.1), -1., 1., 5)
    vgq(rootf(0.1), evalf(0.1), weightf(0.1), -1., 1., 25, atol=1e-13)
    vgq(rootf(0.1), evalf(0.1), weightf(0.1), -1., 1., 100, atol=1e-12)

    vgq(rootf(1), evalf(1), weightf(1), -1., 1., 5)
    vgq(rootf(1), evalf(1), weightf(1), -1., 1., 25, atol=1e-13)
    vgq(rootf(1), evalf(1), weightf(1), -1., 1., 100, atol=1e-12)

    vgq(rootf(10), evalf(10), weightf(10), -1., 1., 5)
    vgq(rootf(10), evalf(10), weightf(10), -1., 1., 25, atol=1e-13)
    vgq(rootf(10), evalf(10), weightf(10), -1., 1., 100, atol=1e-12)

    vgq(rootf(50), evalf(50), weightf(50), -1., 1., 5, atol=1e-13)
    vgq(rootf(50), evalf(50), weightf(50), -1., 1., 25, atol=1e-12)
    vgq(rootf(50), evalf(50), weightf(50), -1., 1., 100, atol=1e-11)

    # this is a special case that the old code supported.
    # when alpha = 0, the gegenbauer polynomial is uniformly 0. but it goes
    # to a scaled down copy of T_n(x) there.
    vgq(rootf(0), orth.eval_chebyt, weightf(0), -1., 1., 5)
    vgq(rootf(0), orth.eval_chebyt, weightf(0), -1., 1., 25)
    vgq(rootf(0), orth.eval_chebyt, weightf(0), -1., 1., 100)

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

    muI, muI_err = integrate.quad(weightf(2), -1, 1)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, orth.cg_roots, 0, 2)
    assert_raises(ValueError, orth.cg_roots, 3.3, 2)
    assert_raises(ValueError, orth.cg_roots, 3, -.75)
Exemple #3
0
def test_cg_roots():
    rootf = lambda a: lambda n, mu: orth.cg_roots(n, a, mu)
    evalf = lambda a: lambda n, x: orth.eval_gegenbauer(n, a, x)
    weightf = lambda a: lambda x: (1 - x**2)**(a - 0.5)

    vgq = verify_gauss_quad
    vgq(rootf(-0.25), evalf(-0.25), weightf(-0.25), -1., 1., 5)
    vgq(rootf(-0.25), evalf(-0.25), weightf(-0.25), -1., 1., 25, atol=1e-12)
    vgq(rootf(-0.25), evalf(-0.25), weightf(-0.25), -1., 1., 100, atol=1e-11)

    vgq(rootf(0.1), evalf(0.1), weightf(0.1), -1., 1., 5)
    vgq(rootf(0.1), evalf(0.1), weightf(0.1), -1., 1., 25, atol=1e-13)
    vgq(rootf(0.1), evalf(0.1), weightf(0.1), -1., 1., 100, atol=1e-12)

    vgq(rootf(1), evalf(1), weightf(1), -1., 1., 5)
    vgq(rootf(1), evalf(1), weightf(1), -1., 1., 25, atol=1e-13)
    vgq(rootf(1), evalf(1), weightf(1), -1., 1., 100, atol=1e-12)

    vgq(rootf(10), evalf(10), weightf(10), -1., 1., 5)
    vgq(rootf(10), evalf(10), weightf(10), -1., 1., 25, atol=1e-13)
    vgq(rootf(10), evalf(10), weightf(10), -1., 1., 100, atol=1e-12)

    vgq(rootf(50), evalf(50), weightf(50), -1., 1., 5, atol=1e-13)
    vgq(rootf(50), evalf(50), weightf(50), -1., 1., 25, atol=1e-12)
    vgq(rootf(50), evalf(50), weightf(50), -1., 1., 100, atol=1e-11)

    # this is a special case that the old code supported.
    # when alpha = 0, the gegenbauer polynomial is uniformly 0. but it goes
    # to a scaled down copy of T_n(x) there.
    vgq(rootf(0), orth.eval_chebyt, weightf(0), -1., 1., 5)
    vgq(rootf(0), orth.eval_chebyt, weightf(0), -1., 1., 25)
    vgq(rootf(0), orth.eval_chebyt, weightf(0), -1., 1., 100)

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

    muI, muI_err = integrate.quad(weightf(2), -1, 1)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, orth.cg_roots, 0, 2)
    assert_raises(ValueError, orth.cg_roots, 3.3, 2)
    assert_raises(ValueError, orth.cg_roots, 3, -.75)
Exemple #4
0
def test_j_roots():
    roots = lambda a, b: lambda n, mu: orth.j_roots(n, a, b, mu)
    evalf = lambda a, b: lambda n, x: orth.eval_jacobi(n, a, b, x)

    verify_gauss_quad(roots(-0.5, -0.75), evalf(-0.5, -0.75), 5)
    verify_gauss_quad(roots(-0.5, -0.75), evalf(-0.5, -0.75), 25, atol=1e-12)
    verify_gauss_quad(roots(-0.5, -0.75), evalf(-0.5, -0.75), 100, atol=1e-11)

    verify_gauss_quad(roots(0.5, -0.5), evalf(0.5, -0.5), 5)
    verify_gauss_quad(roots(0.5, -0.5), evalf(0.5, -0.5), 25, atol=1e-13)
    verify_gauss_quad(roots(0.5, -0.5), evalf(0.5, -0.5), 100, atol=1e-12)

    verify_gauss_quad(roots(1, 0.5), evalf(1, 0.5), 5, atol=2e-13)
    verify_gauss_quad(roots(1, 0.5), evalf(1, 0.5), 25, atol=2e-13)
    verify_gauss_quad(roots(1, 0.5), evalf(1, 0.5), 100, atol=1e-12)

    verify_gauss_quad(roots(0.9, 2), evalf(0.9, 2), 5)
    verify_gauss_quad(roots(0.9, 2), evalf(0.9, 2), 25, atol=1e-13)
    verify_gauss_quad(roots(0.9, 2), evalf(0.9, 2), 100, atol=2e-13)

    verify_gauss_quad(roots(18.24, 27.3), evalf(18.24, 27.3), 5)
    verify_gauss_quad(roots(18.24, 27.3), evalf(18.24, 27.3), 25)
    verify_gauss_quad(roots(18.24, 27.3), evalf(18.24, 27.3), 100, atol=1e-13)

    verify_gauss_quad(roots(47.1, -0.2), evalf(47.1, -0.2), 5, atol=1e-13)
    verify_gauss_quad(roots(47.1, -0.2), evalf(47.1, -0.2), 25, atol=1e-13)
    verify_gauss_quad(roots(47.1, -0.2), evalf(47.1, -0.2), 100, atol=1e-11)

    verify_gauss_quad(roots(2.25, 68.9), evalf(2.25, 68.9), 5)
    verify_gauss_quad(roots(2.25, 68.9), evalf(2.25, 68.9), 25, atol=1e-13)
    verify_gauss_quad(roots(2.25, 68.9), evalf(2.25, 68.9), 100, atol=1e-13)

    # when alpha == beta == 0, P_n^{a,b}(x) == P_n(x)
    xj, wj = orth.j_roots(6, 0.0, 0.0)
    xl, wl = orth.p_roots(6)
    assert_allclose(xj, xl, 1e-14, 1e-14)
    assert_allclose(wj, wl, 1e-14, 1e-14)

    # when alpha == beta != 0, P_n^{a,b}(x) == C_n^{alpha+0.5}(x)
    xj, wj = orth.j_roots(6, 4.0, 4.0)
    xc, wc = orth.cg_roots(6, 4.5)
    assert_allclose(xj, xc, 1e-14, 1e-14)
    assert_allclose(wj, wc, 1e-14, 1e-14)

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

    assert_raises(ValueError, orth.j_roots, 0, 1, 1)
    assert_raises(ValueError, orth.j_roots, 3.3, 1, 1)
    assert_raises(ValueError, orth.j_roots, 3, -2, 1)
    assert_raises(ValueError, orth.j_roots, 3, 1, -2)
    assert_raises(ValueError, orth.j_roots, 3, -2, -2)
Exemple #5
0
def test_j_roots():
    roots = lambda a, b: lambda n, mu: orth.j_roots(n, a, b, mu)
    evalf = lambda a, b: lambda n, x: orth.eval_jacobi(n, a, b, x)

    verify_gauss_quad(roots(-0.5, -0.75), evalf(-0.5, -0.75), 5)
    verify_gauss_quad(roots(-0.5, -0.75), evalf(-0.5, -0.75), 25, atol=1e-12)
    verify_gauss_quad(roots(-0.5, -0.75), evalf(-0.5, -0.75), 100, atol=1e-11)

    verify_gauss_quad(roots(0.5, -0.5), evalf(0.5, -0.5), 5)
    verify_gauss_quad(roots(0.5, -0.5), evalf(0.5, -0.5), 25, atol=1e-13)
    verify_gauss_quad(roots(0.5, -0.5), evalf(0.5, -0.5), 100, atol=1e-12)

    verify_gauss_quad(roots(1, 0.5), evalf(1, 0.5), 5, atol=2e-13)
    verify_gauss_quad(roots(1, 0.5), evalf(1, 0.5), 25, atol=2e-13)
    verify_gauss_quad(roots(1, 0.5), evalf(1, 0.5), 100, atol=1e-12)

    verify_gauss_quad(roots(0.9, 2), evalf(0.9, 2), 5)
    verify_gauss_quad(roots(0.9, 2), evalf(0.9, 2), 25, atol=1e-13)
    verify_gauss_quad(roots(0.9, 2), evalf(0.9, 2), 100, atol=2e-13)

    verify_gauss_quad(roots(18.24, 27.3), evalf(18.24, 27.3), 5)
    verify_gauss_quad(roots(18.24, 27.3), evalf(18.24, 27.3), 25)
    verify_gauss_quad(roots(18.24, 27.3), evalf(18.24, 27.3), 100, atol=1e-13)

    verify_gauss_quad(roots(47.1, -0.2), evalf(47.1, -0.2), 5, atol=1e-13)
    verify_gauss_quad(roots(47.1, -0.2), evalf(47.1, -0.2), 25, atol=1e-13)
    verify_gauss_quad(roots(47.1, -0.2), evalf(47.1, -0.2), 100, atol=1e-11)

    verify_gauss_quad(roots(2.25, 68.9), evalf(2.25, 68.9), 5)
    verify_gauss_quad(roots(2.25, 68.9), evalf(2.25, 68.9), 25, atol=1e-13)
    verify_gauss_quad(roots(2.25, 68.9), evalf(2.25, 68.9), 100, atol=1e-13)

    # when alpha == beta == 0, P_n^{a,b}(x) == P_n(x)
    xj, wj = orth.j_roots(6, 0.0, 0.0)
    xl, wl = orth.p_roots(6)
    assert_allclose(xj, xl, 1e-14, 1e-14)
    assert_allclose(wj, wl, 1e-14, 1e-14)

    # when alpha == beta != 0, P_n^{a,b}(x) == C_n^{alpha+0.5}(x)
    xj, wj = orth.j_roots(6, 4.0, 4.0)
    xc, wc = orth.cg_roots(6, 4.5)
    assert_allclose(xj, xc, 1e-14, 1e-14)
    assert_allclose(wj, wc, 1e-14, 1e-14)

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

    assert_raises(ValueError, orth.j_roots, 0, 1, 1)
    assert_raises(ValueError, orth.j_roots, 3.3, 1, 1)
    assert_raises(ValueError, orth.j_roots, 3, -2, 1)
    assert_raises(ValueError, orth.j_roots, 3, 1, -2)
    assert_raises(ValueError, orth.j_roots, 3, -2, -2)
Exemple #6
0
def test_cg_roots():
    root_func = lambda a: lambda n, mu: orth.cg_roots(n, a, mu)
    eval_func = lambda a: lambda n, x: orth.eval_gegenbauer(n, a, x)

    verify_gauss_quad(root_func(-0.25), eval_func(-0.25), 5)
    verify_gauss_quad(root_func(-0.25), eval_func(-0.25), 25, atol=1e-12)
    verify_gauss_quad(root_func(-0.25), eval_func(-0.25), 100, atol=1e-11)

    verify_gauss_quad(root_func(0.1), eval_func(0.1), 5)
    verify_gauss_quad(root_func(0.1), eval_func(0.1), 25, atol=1e-13)
    verify_gauss_quad(root_func(0.1), eval_func(0.1), 100, atol=1e-12)

    verify_gauss_quad(root_func(1), eval_func(1), 5)
    verify_gauss_quad(root_func(1), eval_func(1), 25, atol=1e-13)
    verify_gauss_quad(root_func(1), eval_func(1), 100, atol=1e-12)

    verify_gauss_quad(root_func(10), eval_func(10), 5)
    verify_gauss_quad(root_func(10), eval_func(10), 25, atol=1e-13)
    verify_gauss_quad(root_func(10), eval_func(10), 100, atol=1e-12)

    verify_gauss_quad(root_func(50), eval_func(50), 5, atol=1e-13)
    verify_gauss_quad(root_func(50), eval_func(50), 25, atol=1e-12)
    verify_gauss_quad(root_func(50), eval_func(50), 100, atol=1e-11)

    # this is a special case that the old code supported. 
    # when alpha = 0, the gegenbauer polynomial is uniformly 0. but it goes
    # to a scaled down copy of T_n(x) there.
    verify_gauss_quad(root_func(0), orth.eval_chebyt, 5)
    verify_gauss_quad(root_func(0), orth.eval_chebyt, 25)
    verify_gauss_quad(root_func(0), orth.eval_chebyt, 100)

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

    assert_raises(ValueError, orth.cg_roots, 0, 2)
    assert_raises(ValueError, orth.cg_roots, 3.3, 2)
    assert_raises(ValueError, orth.cg_roots, 3, -.75)
Exemple #7
0
def test_cg_roots():
    root_func = lambda a: lambda n, mu: orth.cg_roots(n, a, mu)
    eval_func = lambda a: lambda n, x: orth.eval_gegenbauer(n, a, x)

    verify_gauss_quad(root_func(-0.25), eval_func(-0.25), 5)
    verify_gauss_quad(root_func(-0.25), eval_func(-0.25), 25, atol=1e-12)
    verify_gauss_quad(root_func(-0.25), eval_func(-0.25), 100, atol=1e-11)

    verify_gauss_quad(root_func(0.1), eval_func(0.1), 5)
    verify_gauss_quad(root_func(0.1), eval_func(0.1), 25, atol=1e-13)
    verify_gauss_quad(root_func(0.1), eval_func(0.1), 100, atol=1e-12)

    verify_gauss_quad(root_func(1), eval_func(1), 5)
    verify_gauss_quad(root_func(1), eval_func(1), 25, atol=1e-13)
    verify_gauss_quad(root_func(1), eval_func(1), 100, atol=1e-12)

    verify_gauss_quad(root_func(10), eval_func(10), 5)
    verify_gauss_quad(root_func(10), eval_func(10), 25, atol=1e-13)
    verify_gauss_quad(root_func(10), eval_func(10), 100, atol=1e-12)

    verify_gauss_quad(root_func(50), eval_func(50), 5, atol=1e-13)
    verify_gauss_quad(root_func(50), eval_func(50), 25, atol=1e-12)
    verify_gauss_quad(root_func(50), eval_func(50), 100, atol=1e-11)

    # this is a special case that the old code supported.
    # when alpha = 0, the gegenbauer polynomial is uniformly 0. but it goes
    # to a scaled down copy of T_n(x) there.
    verify_gauss_quad(root_func(0), orth.eval_chebyt, 5)
    verify_gauss_quad(root_func(0), orth.eval_chebyt, 25)
    verify_gauss_quad(root_func(0), orth.eval_chebyt, 100)

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

    assert_raises(ValueError, orth.cg_roots, 0, 2)
    assert_raises(ValueError, orth.cg_roots, 3.3, 2)
    assert_raises(ValueError, orth.cg_roots, 3, -.75)
Exemple #8
0
def test_j_roots():
    rf = lambda a, b: lambda n, mu: orth.j_roots(n, a, b, mu)
    ef = lambda a, b: lambda n, x: orth.eval_jacobi(n, a, b, x)
    wf = lambda a, b: lambda x: (1 - x)**a * (1 + x)**b

    vgq = verify_gauss_quad
    vgq(rf(-0.5, -0.75), ef(-0.5, -0.75), wf(-0.5, -0.75), -1., 1., 5)
    vgq(rf(-0.5, -0.75),
        ef(-0.5, -0.75),
        wf(-0.5, -0.75),
        -1.,
        1.,
        25,
        atol=1e-12)
    vgq(rf(-0.5, -0.75),
        ef(-0.5, -0.75),
        wf(-0.5, -0.75),
        -1.,
        1.,
        100,
        atol=1e-11)

    vgq(rf(0.5, -0.5), ef(0.5, -0.5), wf(0.5, -0.5), -1., 1., 5)
    vgq(rf(0.5, -0.5), ef(0.5, -0.5), wf(0.5, -0.5), -1., 1., 25, atol=1.5e-13)
    vgq(rf(0.5, -0.5), ef(0.5, -0.5), wf(0.5, -0.5), -1., 1., 100, atol=1e-12)

    vgq(rf(1, 0.5), ef(1, 0.5), wf(1, 0.5), -1., 1., 5, atol=2e-13)
    vgq(rf(1, 0.5), ef(1, 0.5), wf(1, 0.5), -1., 1., 25, atol=2e-13)
    vgq(rf(1, 0.5), ef(1, 0.5), wf(1, 0.5), -1., 1., 100, atol=1e-12)

    vgq(rf(0.9, 2), ef(0.9, 2), wf(0.9, 2), -1., 1., 5)
    vgq(rf(0.9, 2), ef(0.9, 2), wf(0.9, 2), -1., 1., 25, atol=1e-13)
    vgq(rf(0.9, 2), ef(0.9, 2), wf(0.9, 2), -1., 1., 100, atol=2e-13)

    vgq(rf(18.24, 27.3), ef(18.24, 27.3), wf(18.24, 27.3), -1., 1., 5)
    vgq(rf(18.24, 27.3), ef(18.24, 27.3), wf(18.24, 27.3), -1., 1., 25)
    vgq(rf(18.24, 27.3),
        ef(18.24, 27.3),
        wf(18.24, 27.3),
        -1.,
        1.,
        100,
        atol=1e-13)

    vgq(rf(47.1, -0.2), ef(47.1, -0.2), wf(47.1, -0.2), -1., 1., 5, atol=1e-13)
    vgq(rf(47.1, -0.2),
        ef(47.1, -0.2),
        wf(47.1, -0.2),
        -1.,
        1.,
        25,
        atol=2e-13)
    vgq(rf(47.1, -0.2),
        ef(47.1, -0.2),
        wf(47.1, -0.2),
        -1.,
        1.,
        100,
        atol=1e-11)

    vgq(rf(2.25, 68.9), ef(2.25, 68.9), wf(2.25, 68.9), -1., 1., 5)
    vgq(rf(2.25, 68.9),
        ef(2.25, 68.9),
        wf(2.25, 68.9),
        -1.,
        1.,
        25,
        atol=1e-13)
    vgq(rf(2.25, 68.9),
        ef(2.25, 68.9),
        wf(2.25, 68.9),
        -1.,
        1.,
        100,
        atol=1e-13)

    # when alpha == beta == 0, P_n^{a,b}(x) == P_n(x)
    xj, wj = orth.j_roots(6, 0.0, 0.0)
    xl, wl = orth.p_roots(6)
    assert_allclose(xj, xl, 1e-14, 1e-14)
    assert_allclose(wj, wl, 1e-14, 1e-14)

    # when alpha == beta != 0, P_n^{a,b}(x) == C_n^{alpha+0.5}(x)
    xj, wj = orth.j_roots(6, 4.0, 4.0)
    xc, wc = orth.cg_roots(6, 4.5)
    assert_allclose(xj, xc, 1e-14, 1e-14)
    assert_allclose(wj, wc, 1e-14, 1e-14)

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

    muI, muI_err = integrate.quad(wf(2, 3), -1, 1)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, orth.j_roots, 0, 1, 1)
    assert_raises(ValueError, orth.j_roots, 3.3, 1, 1)
    assert_raises(ValueError, orth.j_roots, 3, -2, 1)
    assert_raises(ValueError, orth.j_roots, 3, 1, -2)
    assert_raises(ValueError, orth.j_roots, 3, -2, -2)