-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_hammer_stroud.py
131 lines (108 loc) · 3.36 KB
/
_hammer_stroud.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import numpy
import sympy
from ..helpers import article
from ._albrecht_collatz import albrecht_collatz as hammer_stroud_11_2
from ._helpers import S2Scheme, register
from ._peirce_1956 import peirce_1956_1, peirce_1956_3
from ._radon import radon
_source = article(
authors=["Preston C. Hammer", "Arthur H. Stroud"],
title="Numerical Evaluation of Multiple Integrals II",
journal="Math. Comp.",
volume="12",
number="64",
year="1958",
month="oct",
pages="272-280",
url="https://doi.org/10.1090/S0025-5718-1958-0102176-6",
)
frac = sympy.Rational
pi = sympy.pi
sqrt = numpy.vectorize(sympy.sqrt)
pm_ = numpy.array([+1, -1])
cos = numpy.vectorize(sympy.cos)
sin = numpy.vectorize(sympy.sin)
def hammer_stroud_12_2():
d = {
"zero2": [[frac(1, 6)]],
"d4_a0": [[frac(1, 6)], [sqrt(frac(1, 2))]],
"sxy": [[frac(1, 24)], [sqrt(frac(1, 2))], [sqrt(frac(1, 2))]],
}
return S2Scheme("Hammer-Stroud 12-2", d, 5, _source)
def hammer_stroud_13_2():
return peirce_1956_1()
def hammer_stroud_17():
# DUP ENH This is Radon's formula.
return radon(0)
def hammer_stroud_18():
# ENH The article only gives floats, but really this is the spherical-product gauss
# formula as described in Strouds book, S2 7-2.
#
# data = [
# (frac(1, 16), fs([0.4247082002778669, 0.1759198966061612])),
# (frac(1, 16), fs([0.8204732385702833, 0.3398511429799874])),
# ]
r1, r2 = sqrt((3 - pm_ * sqrt(3)) / 6)
d = {"d8.0": [[frac(1, 16), frac(1, 16)], [r1, r2]]}
return S2Scheme("Hammer-Stroud 18", d, 7, _source)
def hammer_stroud_19():
sqrt6 = sqrt(6)
alpha1 = (16 + sqrt6) / 288
alpha2 = (137 - 32 * sqrt6) / 1818
alpha3 = (520 + 155 * sqrt6) / 3636 / 8
a = sqrt((6 + sqrt6) / 10)
d = {
"zero2": [[frac(1, 9)]],
"d4_ab": [
[alpha1, alpha3],
[0.5505043204538557, 0.7932084745126058],
[0.2280263556769715, 0.4645097310495256],
],
"d4_a0": [[alpha2], [a]],
}
return S2Scheme("Hammer-Stroud 19", d, 9, _source)
def hammer_stroud_20():
# ENH Also Peirce's formula, even given symbolically.
return peirce_1956_3()
def hammer_stroud_21():
alpha0 = 0.0341505695624825 / numpy.pi
alpha1 = 0.0640242008621985 / numpy.pi
alpha2 = 0.0341505695624825 / numpy.pi
d = {
"d4_ab": [
[alpha0, alpha1, alpha1, alpha1, alpha1, alpha2, alpha2, alpha2],
[
0.2584361661674054,
0.5634263397544869,
0.4776497869993547,
0.8028016728473508,
0.6805823955716280,
0.2190916025980981,
0.9461239423417719,
0.8020851487551318,
],
[
0.0514061496288813,
0.1120724670846205,
0.3191553840796721,
0.1596871812824163,
0.4547506180649039,
0.1463923286035535,
0.1881957532057769,
0.5359361621905023,
],
],
}
return S2Scheme("Hammer-Stroud 21", d, 15, _source)
register(
[
hammer_stroud_11_2,
hammer_stroud_12_2,
hammer_stroud_13_2,
hammer_stroud_17,
hammer_stroud_18,
hammer_stroud_19,
hammer_stroud_20,
hammer_stroud_21,
]
)