Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def stroud_secrest_3(n):
nu = sqrt(n + 1)
data = [(frac(1, 2 ** n), pm(n, nu))]
points, weights = untangle(data)
weights *= enr_volume(n)
return EnrScheme("Stroud-Secrest III", n, weights, points, 3, citation)
def peirce_1956_1():
sqrt29 = sqrt(29)
r = sqrt(frac(3, 4))
s, t = sqrt((27 - pm_ * 3 * sqrt29) / 104)
B1 = frac(2, 27)
# ERR Stroud incorrectly lists 4 instead of 41 here.
B2, B3 = (551 + pm_ * 41 * sqrt29) / 6264
data = [(B1, fsd(2, (r, 1))), (B2, pm(2, s)), (B3, pm(2, t))]
points, weights = untangle(data)
return S2Scheme("Peirce 1956-1", weights, points, 7, _source)
def mysovskih():
sqrt17770 = sqrt(17770)
r, s = sqrt((1715 - pm_ * 7 * sqrt17770) / 2817)
t = sqrt(frac(7, 18))
u = sqrt(frac(7, 27))
B1, B2 = (2965 * sqrt17770 + pm_ * 227816) / 72030 / sqrt17770
B3 = frac(324, 12005)
B4 = frac(2187, 96040)
data = [
(B1, fsd(3, (r, 1))),
(B2, fsd(3, (s, 1))),
(B3, fsd(3, (t, 2))),
(B4, pm(3, u)),
]
points, weights = untangle(data)
return S3Scheme("Mysovskih", _source, 7, weights, points)
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)
def stroud_1966_d(n):
r = sqrt((5 * n - 2 * sqrt(5) + 2 * (n - 1) * sqrt(5 * n + 5)) / (15 * n))
# This sqrt() is imaginary for negative for n=2.
s = sqrt((5 * n - 2 * sqrt(5) - 2 * sqrt(5 * n + 5)) / (15 * n))
t = sqrt((5 + 2 * sqrt(5)) / 15)
w = frac(1, 2 ** n * (n + 1))
data = [(w, _fs11(n, r, s)), (w, pm(n * [t]))]
points, weights = untangle(data)
return CnScheme("Stroud 1966d", n, weights, points, 5, _source, 1.955e-14)
def __init__(self, n, degree, symbolic):
frac = sympy.Rational if symbolic else lambda x, y: x / y
sqrt = sympy.sqrt if symbolic else numpy.sqrt
self.degree = 3
if degree == 3:
reference_volume = 2 ** n
self.weights = numpy.full(2 ** n, frac(reference_volume, 2 ** n))
r = sqrt(3) / 3
self.points = pm(n, r)
else:
lst = n * [[frac(5, 9), frac(8, 9), frac(5, 9)]]
self.weights = numpy.product(
numpy.array(numpy.meshgrid(*lst)).T.reshape(-1, n), axis=-1
)
sqrt35 = sqrt(frac(3, 5))
lst = n * [[-sqrt35, 0, sqrt35]]
self.points = numpy.array(numpy.meshgrid(*lst)).T.reshape(-1, n)
return
sqrt15 = sqrt(15)
r = sqrt((15 + plus_minus * sqrt15) / 4)
s = sqrt((6 - plus_minus * sqrt15) / 2)
t = sqrt((9 + plus_minus * 2 * sqrt15) / 2)
A = (720 + plus_minus * 8 * sqrt15) / 2205
B = (270 - plus_minus * 46 * sqrt15) / 15435
C = (162 + plus_minus * 41 * sqrt15) / 6174
D = (783 - plus_minus * 202 * sqrt15) / 24696
data = [
(A, [[0, 0, 0]]),
(B, fsd(3, (r, 1))),
(C, fsd(3, (s, 2))),
(D, pm([t, t, t])),
]
points, weights = untangle(data)
variant = "a" if positive else "b"
return E3r2Scheme(f"Stroud-Secrest X{variant}", weights, points, 7, source)
self.weights *= \
integrate_monomial_over_unit_nsphere(n * [0], symbolic)
elif index == 'Un 7-1':
self.set_data(Stroud1967(n, symbolic=symbolic))
elif index == 'Un 7-2':
self.degree = 7
A = frac(-n**2, 2**(n+3) * (n+2))
B = frac((n+4)**2, 2**(n+3) * n * (n+2))
r = sqrt(frac(1, n))
s = sqrt(frac(5, n+4))
t = sqrt(frac(1, n+4))
data = [
(A, pm(n, r)),
(B, fsd(n, (s, 1), (t, n-1))),
]
self.points, self.weights = untangle(data)
self.weights *= \
integrate_monomial_over_unit_nsphere(n * [0], symbolic)
else:
assert index == 'Un 11-1'
self.set_data(Stroud1969(n, symbolic=symbolic))
return
def stroud_un_5_2(n):
degree = 5
B1 = frac(1, n * (n + 2))
B2 = frac(n, 2 ** n * (n + 2))
data = [(B1, fsd(n, (1, 1))), (B2, pm(n, sqrt(frac(1, n))))]
points, weights = untangle(data)
return UnScheme("Stroud Un 5-2", n, weights, points, degree, source)