def test_chebyshev_t():
    x, w = gauss_chebyshev_t(1, 17)
    assert [str(r) for r in x] == ['0']
    assert [str(r) for r in w] == ['3.1415926535897932']

    x, w = gauss_chebyshev_t(2, 17)
    assert [str(r) for r in x] == [
            '0.70710678118654752',
            '-0.70710678118654752']
    assert [str(r) for r in w] == [
            '1.5707963267948966',
            '1.5707963267948966']

    x, w = gauss_chebyshev_t(3, 17)
    assert [str(r) for r in x] == [
            '0.86602540378443865',
            '0',
            '-0.86602540378443865']
    assert [str(r) for r in w] == [
            '1.0471975511965977',
            '1.0471975511965977',
            '1.0471975511965977']

    x, w = gauss_chebyshev_t(4, 17)
    assert [str(r) for r in x] == [
            '0.92387953251128676',
            '0.38268343236508977',
            '-0.38268343236508977',
            '-0.92387953251128676']
    assert [str(r) for r in w] == [
            '0.78539816339744831',
            '0.78539816339744831',
            '0.78539816339744831',
            '0.78539816339744831']

    x, w = gauss_chebyshev_t(5, 17)
    assert [str(r) for r in x] == [
            '0.95105651629515357',
            '0.58778525229247313',
            '0',
            '-0.58778525229247313',
            '-0.95105651629515357']
    assert [str(r) for r in w] == [
            '0.62831853071795865',
            '0.62831853071795865',
            '0.62831853071795865',
            '0.62831853071795865',
            '0.62831853071795865']
def test_chebyshev_t():
    x, w = gauss_chebyshev_t(1, 17)
    assert [str(r) for r in x] == ['0']
    assert [str(r) for r in w] == ['3.1415926535897932']

    x, w = gauss_chebyshev_t(2, 17)
    assert [str(r) for r in x] == [
            '0.70710678118654752',
            '-0.70710678118654752']
    assert [str(r) for r in w] == [
            '1.5707963267948966',
            '1.5707963267948966']

    x, w = gauss_chebyshev_t(3, 17)
    assert [str(r) for r in x] == [
            '0.86602540378443865',
            '0',
            '-0.86602540378443865']
    assert [str(r) for r in w] == [
            '1.0471975511965977',
            '1.0471975511965977',
            '1.0471975511965977']

    x, w = gauss_chebyshev_t(4, 17)
    assert [str(r) for r in x] == [
            '0.92387953251128676',
            '0.38268343236508977',
            '-0.38268343236508977',
            '-0.92387953251128676']
    assert [str(r) for r in w] == [
            '0.78539816339744831',
            '0.78539816339744831',
            '0.78539816339744831',
            '0.78539816339744831']

    x, w = gauss_chebyshev_t(5, 17)
    assert [str(r) for r in x] == [
            '0.95105651629515357',
            '0.58778525229247313',
            '0',
            '-0.58778525229247313',
            '-0.95105651629515357']
    assert [str(r) for r in w] == [
            '0.62831853071795865',
            '0.62831853071795865',
            '0.62831853071795865',
            '0.62831853071795865',
            '0.62831853071795865']
Example #3
0
def test_chebyshev_t():
    x, w = gauss_chebyshev_t(1, 17)
    assert [str(r) for r in x] == ["0"]
    assert [str(r) for r in w] == ["3.1415926535897932"]

    x, w = gauss_chebyshev_t(2, 17)
    assert [str(r)
            for r in x] == ["0.70710678118654752", "-0.70710678118654752"]
    assert [str(r) for r in w] == ["1.5707963267948966", "1.5707963267948966"]

    x, w = gauss_chebyshev_t(3, 17)
    assert [str(r) for r in x
            ] == ["0.86602540378443865", "0", "-0.86602540378443865"]
    assert [str(r) for r in w] == [
        "1.0471975511965977",
        "1.0471975511965977",
        "1.0471975511965977",
    ]

    x, w = gauss_chebyshev_t(4, 17)
    assert [str(r) for r in x] == [
        "0.92387953251128676",
        "0.38268343236508977",
        "-0.38268343236508977",
        "-0.92387953251128676",
    ]
    assert [str(r) for r in w] == [
        "0.78539816339744831",
        "0.78539816339744831",
        "0.78539816339744831",
        "0.78539816339744831",
    ]

    x, w = gauss_chebyshev_t(5, 17)
    assert [str(r) for r in x] == [
        "0.95105651629515357",
        "0.58778525229247313",
        "0",
        "-0.58778525229247313",
        "-0.95105651629515357",
    ]
    assert [str(r) for r in w] == [
        "0.62831853071795865",
        "0.62831853071795865",
        "0.62831853071795865",
        "0.62831853071795865",
        "0.62831853071795865",
    ]
def test_chebyshev_t_precise():
    x, w = gauss_chebyshev_t(3, 40)
    assert [str(r) for r in x] == [
        '0.8660254037844386467637231707529361834714',
        '0',
        '-0.8660254037844386467637231707529361834714']
    assert [str(r) for r in w] == [
        '1.047197551196597746154214461093167628066',
        '1.047197551196597746154214461093167628066',
        '1.047197551196597746154214461093167628066']
def test_chebyshev_t_precise():
    x, w = gauss_chebyshev_t(3, 40)
    assert [str(r) for r in x] == [
            '0.8660254037844386467637231707529361834714',
            '0',
            '-0.8660254037844386467637231707529361834714']
    assert [str(r) for r in w] == [
            '1.047197551196597746154214461093167628066',
            '1.047197551196597746154214461093167628066',
            '1.047197551196597746154214461093167628066']
Example #6
0
def _quad_coeffs_hq(M, collocation_type, digits=20):
    if M == 1:
        x = np.array([0.0])
        w = np.array([2.0])

    elif collocation_type == "gauss_legendre":
        from sympy.integrals.quadrature import gauss_legendre
        x, w = gauss_legendre(M, digits)

    elif collocation_type == "gauss_lobatto":
        from sympy.integrals.quadrature import gauss_lobatto
        x, w = gauss_lobatto(M, digits)

    elif collocation_type == "gauss_hermite":
        from sympy.integrals.quadrature import gauss_hermite
        x, w = gauss_hermite(M, 30)
        x = np.array(x, dtype=float)
        w = np.array(w, dtype=float)

    elif collocation_type == "gauss_jacobi":
        from sympy.integrals.quadrature import gauss_jacobi
        x, w = gauss_jacobi(M, 0, 0, 30)
        x = np.array(x, dtype=float)
        w = np.array(w, dtype=float)

    elif collocation_type == "gauss_chebyshev_u":
        from sympy.integrals.quadrature import gauss_chebyshev_u
        x, w = gauss_chebyshev_u(M, 30)
        x = np.array(x, dtype=float)
        w = np.array(w, dtype=float)

    elif collocation_type == "gauss_chebyshev_t":
        from sympy.integrals.quadrature import gauss_chebyshev_t
        x, w = gauss_chebyshev_t(M, 30)
        x = np.array(x, dtype=float)
        w = np.array(w, dtype=float)

    else:
        raise Exception("Unknown collocation method '" +
                        str(collocation_type) + "'")

    assert len(x) == M

    return x, w