def test_roots_sh_chebyu():
    weightf = orth.sh_chebyu(5).weight_func
    verify_gauss_quad(sc.roots_sh_chebyu, sc.eval_sh_chebyu, weightf, 0., 1., 5)
    verify_gauss_quad(sc.roots_sh_chebyu, sc.eval_sh_chebyu, weightf, 0., 1., 25)
    verify_gauss_quad(sc.roots_sh_chebyu, sc.eval_sh_chebyu, weightf, 0., 1.,
                      100, atol=1e-13)

    x, w = sc.roots_sh_chebyu(5, False)
    y, v, m = sc.roots_sh_chebyu(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, 1)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, sc.roots_sh_chebyu, 0)
    assert_raises(ValueError, sc.roots_sh_chebyu, 3.3)
Exemple #2
0
 def test_sh_chebyu(self):
     # U*_n(x) = U_n(2x-1)
     psub = np.poly1d([2, -1])
     Us0 = orth.sh_chebyu(0)
     Us1 = orth.sh_chebyu(1)
     Us2 = orth.sh_chebyu(2)
     Us3 = orth.sh_chebyu(3)
     Us4 = orth.sh_chebyu(4)
     Us5 = orth.sh_chebyu(5)
     use0 = orth.chebyu(0)(psub)
     use1 = orth.chebyu(1)(psub)
     use2 = orth.chebyu(2)(psub)
     use3 = orth.chebyu(3)(psub)
     use4 = orth.chebyu(4)(psub)
     use5 = orth.chebyu(5)(psub)
     assert_array_almost_equal(Us0.c, use0.c, 13)
     assert_array_almost_equal(Us1.c, use1.c, 13)
     assert_array_almost_equal(Us2.c, use2.c, 13)
     assert_array_almost_equal(Us3.c, use3.c, 13)
     assert_array_almost_equal(Us4.c, use4.c, 12)
     assert_array_almost_equal(Us5.c, use5.c, 11)