Example #1
0
def test_legendre():
    x, w = gauss_legendre(1, 17)
    assert [str(r) for r in x] == ['0']
    assert [str(r) for r in w] == ['2.0000000000000000']

    x, w = gauss_legendre(2, 17)
    assert [str(r)
            for r in x] == ['-0.57735026918962576', '0.57735026918962576']
    assert [str(r) for r in w] == ['1.0000000000000000', '1.0000000000000000']

    x, w = gauss_legendre(3, 17)
    assert [str(r) for r in x
            ] == ['-0.77459666924148338', '0', '0.77459666924148338']
    assert [str(r) for r in w] == [
        '0.55555555555555556', '0.88888888888888889', '0.55555555555555556'
    ]

    x, w = gauss_legendre(4, 17)
    assert [str(r) for r in x] == [
        '-0.86113631159405258', '-0.33998104358485626', '0.33998104358485626',
        '0.86113631159405258'
    ]
    assert [str(r) for r in w] == [
        '0.34785484513745386', '0.65214515486254614', '0.65214515486254614',
        '0.34785484513745386'
    ]
Example #2
0
def test_legendre_precise():
    x, w = gauss_legendre(3, 40)
    assert [str(r) for r in x] == \
        ['-0.7745966692414833770358530799564799221666', '0',
         '0.7745966692414833770358530799564799221666']
    assert [str(r) for r in w] == \
        ['0.5555555555555555555555555555555555555556',
         '0.8888888888888888888888888888888888888889',
         '0.5555555555555555555555555555555555555556']
Example #3
0
def test_legendre_precise():
    x, w = gauss_legendre(3, 40)
    assert [str(r) for r in x] == \
            ['-0.7745966692414833770358530799564799221666', '0',
                    '0.7745966692414833770358530799564799221666']
    assert [str(r) for r in w] == \
            ['0.5555555555555555555555555555555555555556',
                    '0.8888888888888888888888888888888888888889',
                    '0.5555555555555555555555555555555555555556']
Example #4
0
def test_legendre():
    x, w = gauss_legendre(1, 17)
    assert [str(r) for r in x] == ['0']
    assert [str(r) for r in w] == ['2.0000000000000000']

    x, w = gauss_legendre(2, 17)
    assert [str(r) for r in x] == ['-0.57735026918962576',
                                   '0.57735026918962576']
    assert [str(r) for r in w] == ['1.0000000000000000', '1.0000000000000000']

    x, w = gauss_legendre(3, 17)
    assert [str(r) for r in x] == ['-0.77459666924148338', '0',
                                   '0.77459666924148338']
    assert [str(r) for r in w] == ['0.55555555555555556',
                                   '0.88888888888888889', '0.55555555555555556']

    x, w = gauss_legendre(4, 17)
    assert [str(r) for r in x] == ['-0.86113631159405258',
                                   '-0.33998104358485626', '0.33998104358485626',
                                   '0.86113631159405258']
    assert [str(r) for r in w] == ['0.34785484513745386',
                                   '0.65214515486254614', '0.65214515486254614',
                                   '0.34785484513745386']