-
Notifications
You must be signed in to change notification settings - Fork 2
/
approximations.py
139 lines (133 loc) · 12.8 KB
/
approximations.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
132
133
134
135
136
137
138
139
import numpy as np
def get_square_root_polynomial_approximation_coefficients(n: int) -> np.ndarray:
return np.array(
[c[0] + 1j * c[1] for c in _get_square_root_polynomial_approximation_coefficients(n)])
def _get_square_root_polynomial_approximation_coefficients(n: int) -> np.ndarray:
if n == 40:
return np.array(
[(0.4866279871730228, 0.0), (6.7753360791013675, 0.2189959966414623),
(6.7753360791013675, -0.2189959966414623),
(3.3592490981811367, 0.5794768567703864), (3.3592490981811367, -0.5794768567703864),
(2.3057654166554027, 0.5289261020828417), (2.3057654166554027, -0.5289261020828417),
(5.409759891887645, 0.4997756985166228), (5.409759891887645, -0.4997756985166228),
(0.9619869027848595, 0.3576245386704108), (0.9619869027848595, -0.3576245386704108),
(6.217629417041913, 0.37797666477283487), (6.217629417041913, -0.37797666477283487),
(0.6198411404784826, 0.2828897952470256), (0.6198411404784826, -0.2828897952470256),
(4.426723824727492, 0.5695983383623333), (4.426723824727492, -0.5695983383623333),
(1.8149459185702093, 0.4829462193972209), (1.8149459185702093, -0.4829462193972209),
(6.9426604071261036, 0.13188993516743172), (6.9426604071261036, -0.13188993516743172),
(0.34528740608873676, 0.20400851695655042), (0.34528740608873676, -0.20400851695655042),
(4.934748879980455, 0.5418513720271881), (4.934748879980455, -0.5418513720271881),
(2.8245478812459495, 0.5614838808102214), (2.8245478812459495, -0.5614838808102214),
(6.5316463576247115, 0.30196360921770654), (6.5316463576247115, -0.30196360921770654),
(0.14532315096196874, 0.12476760679349806), (0.14532315096196874, -0.12476760679349806),
(5.840729170950718, 0.4445991239382713), (5.840729170950718, -0.4445991239382713),
(1.3635061106577069, 0.42515546075133986), (1.3635061106577069, -0.42515546075133986),
(7.02862869086651, 0.04375207292652774), (7.02862869086651, -0.04375207292652774),
(3.897467167459577, 0.5822413481996916), (3.897467167459577, -0.5822413481996916),
(0.026378769724500133, 0.05052277593366429), (0.026378769724500133, -0.05052277593366429)])
elif n == 80:
return np.array(
[(5.2045714957721212e-01, 0.), (5.0083255305075394e+00, 3.1194426902495376e-01),
(5.0083255305075394e+00, -3.1194426902495376e-01), (2.1125773787980999e+00, 3.0063514519299894e-01),
(2.1125773787980999e+00, -3.0063514519299894e-01), (6.5690492423765754e+00, 1.6502466944756988e-01),
(6.5690492423765754e+00, -1.6502466944756988e-01), (8.1709044309848589e-01, 1.9333457188772807e-01),
(8.1709044309848589e-01, -1.9333457188772807e-01), (3.7016292969849922e+00, 3.4040589363169776e-01),
(3.7016292969849922e+00, -3.4040589363169776e-01), (5.9023592338008379e+00, 2.5146205660049509e-01),
(5.9023592338008379e+00, -2.5146205660049509e-01), (3.6929261464897156e-01, 1.2462430229930388e-01),
(3.6929261464897156e-01, -1.2462430229930388e-01), (6.9447460351718391e+00, 6.3839728064831597e-02),
(6.9447460351718391e+00, -6.3839728064831597e-02), (2.8907300776726794e+00, 3.3030905943459354e-01),
(2.8907300776726794e+00, -3.3030905943459354e-01), (1.1974000523548334e+00, 2.3487064210696665e-01),
(1.1974000523548334e+00, -2.3487064210696665e-01), (4.5019173218593256e+00, 3.3002560428386885e-01),
(4.5019173218593256e+00, -3.3002560428386885e-01), (9.0007093424779305e-02, 5.4679696710979948e-02),
(9.0007093424779305e-02, -5.4679696710979948e-02), (6.7962763576810419e+00, 1.1541007173052707e-01),
(6.7962763576810419e+00, -1.1541007173052707e-01), (5.4788777412690388e+00, 2.8549532400799915e-01),
(5.4788777412690388e+00, -2.8549532400799915e-01), (1.6326965737140866e+00, 2.7107580771200218e-01),
(1.6326965737140866e+00, -2.7107580771200218e-01), (3.1595187487766285e+00, 3.3592438044324285e-01),
(3.1595187487766285e+00, -3.3592438044324285e-01), (6.2686684844018599e+00, 2.1088018332235661e-01),
(6.2686684844018599e+00, -2.1088018332235661e-01), (1.6316744591201501e-01, 7.7561722148524206e-02),
(1.6316744591201501e-01, -7.7561722148524206e-02), (6.9880863085194047e+00, 3.8005512140200169e-02),
(6.9880863085194047e+00, -3.8005512140200169e-02), (6.5046260219363339e-01, 1.7105516017321826e-01),
(6.5046260219363339e-01, -1.7105516017321826e-01), (4.2390119343484907e+00, 3.3575638400976215e-01),
(4.2390119343484907e+00, -3.3575638400976215e-01), (2.3656930878752762e+00, 3.1258626589940358e-01),
(2.3656930878752762e+00, -3.1258626589940358e-01), (6.0932416424730427e+00, 2.3191550975770611e-01),
(6.0932416424730427e+00, -2.3191550975770611e-01), (3.7610146903157830e-02, 3.2919956878332234e-02),
(3.7610146903157830e-02, -3.2919956878332234e-02), (5.2488076895027218e+00, 2.9972289017666387e-01),
(5.2488076895027218e+00, -2.9972289017666387e-01), (1.4087976924540682e+00, 2.5372818417932474e-01),
(1.4087976924540682e+00, -2.5372818417932474e-01), (6.8806448318972375e+00, 8.9741687797041267e-02),
(6.8806448318972375e+00, -8.9741687797041267e-02), (3.4303569545647967e+00, 3.3930112248366689e-01),
(3.4303569545647967e+00, -3.3930112248366689e-01), (5.0089278024200690e-01, 1.4806714005459057e-01),
(5.0089278024200690e-01, -1.4806714005459057e-01), (6.4275891307570072e+00, 1.8852277924851088e-01),
(6.4275891307570072e+00, -1.8852277924851088e-01), (1.8677579257387020e+00, 2.8675773594082060e-01),
(1.8677579257387020e+00, -2.8675773594082060e-01), (4.7588660474218250e+00, 3.2206956186339697e-01),
(4.7588660474218250e+00, -3.2206956186339697e-01), (2.5647697808840020e-01, 1.0101209954712984e-01),
(2.5647697808840020e-01, -1.0101209954712984e-01), (6.6921951374957551e+00, 1.4058253437116788e-01),
(6.6921951374957551e+00, -1.4058253437116788e-01), (2.6255942696025123e+00, 3.2250658108556646e-01),
(2.6255942696025123e+00, -3.2250658108556646e-01), (3.9717178853788155e+00, 3.3922339159801218e-01),
(3.9717178853788155e+00, -3.3922339159801218e-01), (5.6971626603131753e+00, 2.6936773468703379e-01),
(5.6971626603131753e+00, -2.6936773468703379e-01), (9.9976919996136360e-01, 2.1467600352493088e-01),
(9.9976919996136360e-01, -2.1467600352493088e-01), (7.0101183338631925e+00, 1.2557055355603208e-02),
(7.0101183338631925e+00, -1.2557055355603208e-02), (6.7726709213268323e-03, 1.3221971412430250e-02),
(6.7726709213268323e-03, -1.3221971412430250e-02)])
raise RuntimeError("Polynomial approximations", n, "not found")
heatbath_rational_approximation_coefficients = np.array(
[-4981.4306470712730693405, -8.9382825602643111093004, -1.2457162771913856295872, -0.37167263185428896748638,
-0.15031571215565192001270, -0.070843479130421928460910, -0.036310181507273187816262, -0.019520301144985825780877,
-0.010787675237797089978906, -0.0060579866772544655350487, -0.0034336460224096289796546,
-0.0019565160560088558896672, -0.0011181272751471035430915, -0.00063999085821798348127658,
-0.00036658238252260816658172, -0.00021002500120986991244087, -0.00012032190237786255433630,
-0.000068915432370619956890537, -0.000039458461055523395541546, -0.000022583250018701918819698,
-0.000012919182443166200580206, -0.0000073870199468108516079189, -0.0000042215693878609854014908,
-0.0000024112205479619004383730, -0.0000013764318281247878155307, -0.00000078529837702298934848698,
-0.00000044780400821105928043260, -0.00000025522047736259276168467, -0.00000014537764150563968984071,
-0.000000082753330231548739648546, -0.000000047063242097171590724142, -0.000000026729221558979387675184,
-0.000000015144280407387797810626, -0.0000000085382776042134972631842, -0.0000000047585505425284105327310,
-0.0000000025731785676938602060340, -0.0000000012730323955774180138165, -0.00000000044809941497180293347425,
-3638.9036348501045371995, 61.874519845389900154857, 16.573405486734320966016, 6.9293996590684097718284,
3.4325358638380201838250, 1.8445338227999974274552, 1.0347873358068314820395, 0.59452345865618051347067,
0.34621364406325925799596, 0.20316541780144645411815, 0.11973781755821199365269, 0.070735899392359384908413,
0.041838466116724549668281, 0.024759582103476380434832, 0.014654359135220436532760, 0.0086724386988493391237450,
0.0051310105846745345915362, 0.0030346750756372170153183, 0.0017940841311553522304840, 0.0010601692845855638556739,
0.00062617052912822084950478, 0.00036963959629010970331361, 0.00021807961013696093567250,
0.00012858229723527918335611, 0.000075761014661145500135662, 0.000044601869111935329965154,
0.000026229944038314633607951, 0.000015402330832267124256983, 0.0000090236967396935620449194,
0.0000052676183396631373371477, 0.0000030569071282552108557470, 0.0000017565478686544079614317,
0.00000099240452123455419371103, 0.00000054425140707859096819118, 0.00000028271480632531249130664,
0.00000013217077749271971462629, 0.000000049022221942602181987839, 0.0000000091473545957420055377361])
force_level1_rational_approximation_coefficients = np.array(
[117.647178763863820550450195, 0.808691711322313443088135372, 0.112549231713699223479027421,
0.0159772219693554396200780811, 164.005923501959795192365038, 3.29927200025897500905469184,
0.352232013648044570434835559, 0.0236838805225839621645977611])
force_level2_rational_approximation_coefficients = np.array(
[174.94162757018514076313637, -117.64717876386382055045019, 1.2351420966722137291779740,
-0.80869171132231344308813537, 0.21285748861080790718117340, -0.11254923171369922347902742,
0.049939093038846463936908106, -0.015977221969355439620078081, 0.010919772604915153289559469,
0.001598529456169421639337453, 0.00018583674177677333097914351, 259.81793767955786391529083,
164.00592350195979519236504, 6.2593067721116072815097601, 3.2992720002589750090546918, 1.0393512345531980330767458,
0.35223201364804457043483556, 0.18687808773678415745587179, 0.023683880522583962164597761,
0.027939757132256621107679226, 0.0028465701870511722306991735, 0.00012240422529956592668225567])
force_level3_rational_approximation_coefficients = np.array(
[248.88396737624975349911156, -174.94162757018514076313637, 1.7709406868090960278721408,
-1.2351420966722137291779740, 0.33441216283549203490717507, -0.21285748861080790718117340,
0.097724845734538418376512558, -0.049939093038846463936908106, 0.030800186396001571102913629,
-0.010919772604915153289559469, 0.0092888208367651715702614726, 0.0025238287353378325574746575,
-0.001598529456169421639337453, 0.00058382059698073709578371747, -0.00018583674177677333097914351,
0.00010486000927275519833400471, 0.000011737037888366007614817894, 390.18283373799182641438344,
259.81793767955786391529083, 10.379532102272641226325450, 6.2593067721116072815097601, 2.1543260955307938783242414,
1.0393512345531980330767458, 0.55338468548135525731225989, 0.18687808773678415745587179,
0.14042233084511524179978504, 0.027939757132256621107679226, 0.032410490431473927988104724,
0.0064226324404127247222753198, 0.0028465701870511722306991735, 0.0010147352356195413930896814,
0.00012240422529956592668225567, 0.00011103971058204385738474323, 0.0000055234436521541712966213781])
metropolis_rational_approximation_coefficients = np.array(
[418.222502342153421718954329, 2.97981004766376018454367844, 0.595021815158570580715239308,
0.202609122908542202913004285, 0.0824978663713450601325097362, 0.0355447951549982502441726191,
0.0153873342201100363030804945, 0.00653002002912066209732111280, 0.00267953685509986737979014989,
0.00105261537957298538332555959, 0.000392051687804974901676889541, 0.000136855695343733011791847833,
0.0000440843867866555324313432738, 0.0000128113916997842275360933561, 0.00000324102112703852882596084510,
0.000000670702559821339715431544248, 0.000000100465541603639482622454774, 708.456969133708774250236839,
20.5545836704482543092111935, 5.16460586130848066092696251, 1.77335742461795338089518681,
0.663483773139054161068555408, 0.251260388600611110026798526, 0.0933210176761593454438480966,
0.0334329670158591978976640839, 0.0114225244703120473204264627, 0.00368309198965533868820332893,
0.00110757598877812519195949185, 0.000305911192767903423411472490, 0.0000759625965715284538520399041,
0.0000164241384694373051997536552, 0.00000293320679744054879906466158, 0.000000390128040236098295575734048,
0.0000000269253347571438797470449799])