How to use the quadpy.helpers.z function in quadpy

To help you get started, we’ve selected a few quadpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / quadpy / quadpy / s2 / _radon.py View on Github external
def radon(alpha):
    r = sqrt(frac(alpha + 4, alpha + 6))
    s = sqrt(frac(alpha + 4, 4 * (alpha + 6)))
    t = sqrt(frac(3 * (alpha + 4), 4 * (alpha + 6)))

    A = frac(4, (alpha + 4) ** 2)
    B = frac((alpha + 2) * (alpha + 6), 6 * (alpha + 4) ** 2)

    data = [
        (A, z(2)),
        (B, numpy.array([[+r, 0], [-r, 0]])),
        # Stroud is missing +- in front of t.
        (B, numpy.array([[+s, +t], [-s, +t], [+s, -t], [-s, -t]])),
    ]

    points, weights = untangle(data)
    return S2Scheme(f"Radon({alpha})", weights, points, 5, _source)
github nschloe / quadpy / tools / improve_precision.py View on Github external
def f(x):
        degree = 11
        n = 3

        u = 0.871_740_148_509_601
        v = 0.591_700_181_433_148
        w = 0.209_299_217_902_484

        # u = x[0]
        # v = x[1]
        # w = x[2]
        # B = x[3:]
        B = x

        data = [
            (B[0], z(n)),
            (B[1], fsd(n, (u, 1))),
            (B[2], fsd(n, (v, 1))),
            (B[3], fsd(n, (w, 1))),
            (B[4], fsd(n, (u, 2))),
            (B[5], fsd(n, (v, 2))),
            (B[6], fsd(n, (w, 2))),
            (B[7], fsd(n, (u, 1), (v, 1))),
            (B[8], fsd(n, (u, 1), (w, 1))),
            (B[9], fsd(n, (u, 3))),
            (B[10], fsd(n, (v, 3))),
            (B[11], fsd(n, (w, 3))),
            (B[12], fsd(n, (u, 2), (v, 1))),
        ]

        points, weights = untangle(data)
github nschloe / quadpy / quadpy / cn / _tyler.py View on Github external
def tyler(n):
    data = [(frac(3 - n, 3), z(n)), (frac(1, 6), fsd(n, (1, 1)))]
    points, weights = untangle(data)
    return CnScheme("Tyler", n, weights, points, 3, _source)
github nschloe / quadpy / quadpy / cn / _ewing.py View on Github external
def ewing(n):
    data = [(frac(2, 3), z(n)), (frac(1, 3 * 2 ** n), pm(n, 1))]
    points, weights = untangle(data)
    return CnScheme("Ewing", n, weights, points, 3, _source)
github nschloe / quadpy / quadpy / sn / _stenger.py View on Github external
#         -0.373831314185824e+02,
        #         -0.141469445049282e-01,
        #         +0.104863970436266,
        #         -0.973070178977534e-03,
        #         -0.862234640073899e-02,
        #         +0.654476925250512e+01,
        #         +0.153312717360660e-02,
        #         -0.611928443128898e-04,
        #         +0.622126777947090e-02,
        #         +0.887274197302674e-05,
        #     ],
        # ),
    }[n]

    data = [
        (B[0], z(n)),
        (B[1], fsd(n, (u, 1))),
        (B[2], fsd(n, (v, 1))),
        (B[3], fsd(n, (w, 1))),
        (B[4], fsd(n, (u, 2))),
        (B[5], fsd(n, (v, 2))),
        (B[6], fsd(n, (w, 2))),
        (B[7], fsd(n, (u, 1), (v, 1))),
        (B[8], fsd(n, (u, 1), (w, 1))),
        (B[9], fsd(n, (u, 3))),
        (B[10], fsd(n, (v, 3))),
        (B[11], fsd(n, (w, 3))),
        (B[12], fsd(n, (u, 2), (v, 1))),
    ]
    if n > 3:
        data += [(B[13], fsd(n, (u, 4))), (B[14], fsd(n, (v, 4)))]
    if n > 4:
github nschloe / quadpy / quadpy / enr2 / _stenger.py View on Github external
[
                -0.361840434143098e2,
                -0.447936529138517,
                +0.112077863004144e2,
                +0.392940404320855e-2,
                -0.254859786784158e1,
                +0.775156917007496e-1,
                -0.130980134773619e-2,
                +0.509719573568315,
                +0.436600449245395e-3,
            ],
        ),
    }[dim]

    data = [
        (B[0], z(dim)),
        (B[1], fsd(dim, (u, 1))),
        (B[2], fsd(dim, (v, 1))),
        (B[3], fsd(dim, (u, 2))),
        (B[4], fsd(dim, (v, 2))),
        (B[5], fsd(dim, (u, 1), (v, 1))),
        (B[6], fsd(dim, (u, 3))),
        (B[7], fsd(dim, (v, 3))),
    ]
    if dim > 3:
        data += [(B[8], fsd(dim, (u, 4)))]

    points, weights = untangle(data)
    weights /= math.sqrt(math.pi) ** dim
    return Enr2Scheme("Stenger 9a", dim, weights, points, 9, source)
github nschloe / quadpy / quadpy / enr2 / _stenger.py View on Github external
-0.670700680243651e2,
                -0.856090560229205e-2,
                +0.794446232770302e-1,
                -0.220272863263544e-3,
                -0.373515812228225e-2,
                +0.123606544052884e2,
                +0.537788804557843e-3,
                -0.122101861480881e-4,
                +0.725117070759373e-2,
                +0.331725011358320e-5,
            ],
        ),
    }[dim]

    data = [
        (B[0], z(dim)),
        (B[1], fsd(dim, (u, 1))),
        (B[2], fsd(dim, (v, 1))),
        (B[3], fsd(dim, (w, 1))),
        (B[4], fsd(dim, (u, 2))),
        (B[5], fsd(dim, (v, 2))),
        (B[6], fsd(dim, (w, 2))),
        (B[7], fsd(dim, (u, 1), (v, 1))),
        (B[8], fsd(dim, (u, 1), (w, 1))),
        (B[9], fsd(dim, (u, 3))),
        (B[10], fsd(dim, (v, 3))),
        (B[11], fsd(dim, (w, 3))),
        (B[12], fsd(dim, (u, 2), (v, 1))),
    ]
    if dim > 3:
        data += [(B[13], fsd(dim, (u, 4))), (B[14], fsd(dim, (v, 4)))]
    if dim > 4:
github nschloe / quadpy / quadpy / enr2 / _stenger.py View on Github external
6: (
            0.165068012388578e1,
            0.524647623275290,
            [
                +0.616293651884027e3,
                +0.107529736766179e1,
                -0.113807008098269e3,
                -0.610828352270520e-1,
                +0.127887706992535e2,
                +0.239492607623178e-1,
            ],
        ),
    }[dim]

    data = [
        (B[0], z(dim)),
        (B[1], fsd(dim, (u, 1))),
        (B[2], fsd(dim, (v, 1))),
        (B[3], fsd(dim, (u, 2))),
        (B[4], fsd(dim, (v, 2))),
        (B[5], fsd(dim, (u, 3))),
    ]
    points, weights = untangle(data)
    weights /= math.sqrt(math.pi) ** dim
    return Enr2Scheme("Stenger 7b", dim, weights, points, 7, source)
github nschloe / quadpy / quadpy / cn / _mcnamee_stenger.py View on Github external
]
    A1 = -2 * (n - 1) * A11 + frac(1, 2) * (inv[0][0] * vec[0] + inv[0][1] * vec[1])
    A2 = -2 * (n - 1) * A22 + frac(1, 2) * (inv[1][0] * vec[0] + inv[1][1] * vec[1])

    A0 = (
        I0
        - 2 * n * (A1 + A2)
        - 2 ** 2 * comb(n, 2) * (A11 + A22)
        - 2 ** 3 * comb(n, 3) * A111
    )

    u = sqrt(u2)
    v = sqrt(v2)

    data = [
        (A0, z(n)),
        (A1, fsd(n, (u, 1))),
        (A2, fsd(n, (v, 1))),
        (A11, fsd(n, (u, 2))),
        (A22, fsd(n, (v, 2))),
        (A111, fsd(n, (u, 3))),
    ]

    points, weights = untangle(data)

    weights /= I0
    variant = "a" if not switch_uv else "b"
    return f"McNamee-Stenger 7{variant}", n, weights, points, 7, _source
github nschloe / quadpy / quadpy / c3 / _hammer_stroud.py View on Github external
r2 = (33 - i * sqrt(165)) / 28
    s2 = (30 + i * sqrt(165)) / 35
    t2 = (195 - i * 4 * sqrt(165)) / 337

    r = sqrt(r2)
    s = sqrt(s2)
    t = sqrt(t2)

    B1 = 176 / r2 ** 3 / 945
    B2 = 8 / s2 ** 3 / 135
    B3 = 8 / t2 ** 3 / 216
    B0 = 8 - 6 * B1 - 12 * B2 - 8 * B3

    data = [
        (B0, z(3)),
        (B1, fsd(3, (r, 1))),
        (B2, fsd(3, (s, 2))),
        (B3, pm([t, t, t])),
    ]
    points, weights = untangle(data)
    weights /= 8
    variant = "a" if variant_a else "b"
    return C3Scheme(f"Hammer-Stroud 5-3{variant}", weights, points, 7, _source)