flint-sys 0.9.0

Bindings to the FLINT C library
Documentation
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
/*
    Copyright (C) 2020 Fredrik Johansson

    This file is part of FLINT.

    FLINT is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.  See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "acb.h"

#define NUM_TESTS 256
const double agm_testdata[NUM_TESTS][6] = {
    {-1, -1, -1, -1, -1.00000000000000, -1.00000000000000},
    {-1, -1, -1, 0, -1.04916052873278, -0.478155746088161},
    {-1, -1, -1, 1, -1.19814023473559, 0.000000000000000},
    {-1, -1, -1, 2, -1.35980258211696, 0.412918513270561},
    {-1, -1, 0, -1, -0.478155746088161, -1.04916052873278},
    {-1, -1, 0, 0, 0.000000000000000, 0.000000000000000},
    {-1, -1, 0, 1, -0.778004078788958, 0.188411067988680},
    {-1, -1, 0, 2, -0.966415146777638, 0.589593010800278},
    {-1, -1, 1, -1, 0.000000000000000, -1.19814023473559},
    {-1, -1, 1, 0, 0.188411067988680, -0.778004078788958},
    {-1, -1, 1, 1, 0.000000000000000, 0.000000000000000},
    {-1, -1, 1, 2, -0.574659643809835, 0.810208383866421},
    {-1, -1, 2, -1, 0.412918513270561, -1.35980258211696},
    {-1, -1, 2, 0, 0.589593010800278, -0.966415146777638},
    {-1, -1, 2, 1, 0.810208383866421, -0.574659643809835},
    {-1, -1, 2, 2, 1.08423239187061, -0.238299975053003},
    {-1, 0, -1, -1, -1.04916052873278, -0.478155746088161},
    {-1, 0, -1, 0, -1.00000000000000, 0.000000000000000},
    {-1, 0, -1, 1, -1.04916052873278, 0.478155746088161},
    {-1, 0, -1, 2, -1.13815978557677, 0.897764105638205},
    {-1, 0, 0, -1, -0.599070117367796, -0.599070117367796},
    {-1, 0, 0, 0, 0.000000000000000, 0.000000000000000},
    {-1, 0, 0, 1, -0.599070117367796, 0.599070117367796},
    {-1, 0, 0, 2, -0.742646422399778, 1.01005159361958},
    {-1, 0, 1, -1, -0.188411067988680, -0.778004078788958},
    {-1, 0, 1, 0, 0.000000000000000, 0.000000000000000},
    {-1, 0, 1, 1, -0.188411067988680, 0.778004078788958},
    {-1, 0, 1, 2, -0.363823969691055, 1.15631976909117},
    {-1, 0, 2, -1, 0.178866979357132, -0.985872907297986},
    {-1, 0, 2, 0, 0.422966208408802, 0.661266183461805},
    {-1, 0, 2, 1, 0.178866979357132, 0.985872907297986},
    {-1, 0, 2, 2, -0.0126420344317752, 1.32391495927282},
    {-1, 1, -1, -1, -1.19814023473559, 0.000000000000000},
    {-1, 1, -1, 0, -1.04916052873278, 0.478155746088161},
    {-1, 1, -1, 1, -1.00000000000000, 1.00000000000000},
    {-1, 1, -1, 2, -1.02005412633766, 1.47134936286465},
    {-1, 1, 0, -1, -0.778004078788958, -0.188411067988680},
    {-1, 1, 0, 0, 0.000000000000000, 0.000000000000000},
    {-1, 1, 0, 1, -0.478155746088161, 1.04916052873278},
    {-1, 1, 0, 2, -0.571004782644619, 1.52731627482094},
    {-1, 1, 1, -1, 0.000000000000000, 0.000000000000000},
    {-1, 1, 1, 0, 0.188411067988680, 0.778004078788958},
    {-1, 1, 1, 1, 0.000000000000000, 1.19814023473559},
    {-1, 1, 1, 2, -0.136827548397369, 1.62780548487271},
    {-1, 1, 2, -1, 0.810208383866421, 0.574659643809835},
    {-1, 1, 2, 0, 0.589593010800278, 0.966415146777638},
    {-1, 1, 2, 1, 0.412918513270561, 1.35980258211696},
    {-1, 1, 2, 2, 0.267405171219803, 1.75269801601936},
    {-1, 2, -1, -1, -1.35980258211696, 0.412918513270561},
    {-1, 2, -1, 0, -1.13815978557677, 0.897764105638205},
    {-1, 2, -1, 1, -1.02005412633766, 1.47134936286465},
    {-1, 2, -1, 2, -1.00000000000000, 2.00000000000000},
    {-1, 2, 0, -1, -0.985872907297986, 0.178866979357132},
    {-1, 2, 0, 0, 0.000000000000000, 0.000000000000000},
    {-1, 2, 0, 1, -0.420983902077155, 1.47839688785392},
    {-1, 2, 0, 2, -0.493004461502931, 2.02900451838781},
    {-1, 2, 1, -1, 0.574659643809835, 0.810208383866421},
    {-1, 2, 1, 0, 0.363823969691055, 1.15631976909117},
    {-1, 2, 1, 1, 0.136827548397369, 1.62780548487271},
    {-1, 2, 1, 2, 0.000000000000000, 2.11638793788003},
    {-1, 2, 2, -1, 0.963366302386887, 0.963366302386887},
    {-1, 2, 2, 0, 0.777111977967075, 1.37110999239961},
    {-1, 2, 2, 1, 0.599070117367796, 1.79721035210339},
    {-1, 2, 2, 2, 0.455159607692816, 2.23571522629432},
    {0, -1, -1, -1, -0.478155746088161, -1.04916052873278},
    {0, -1, -1, 0, -0.599070117367796, -0.599070117367796},
    {0, -1, -1, 1, -0.778004078788958, -0.188411067988680},
    {0, -1, -1, 2, -0.985872907297986, 0.178866979357132},
    {0, -1, 0, -1, 0.000000000000000, -1.00000000000000},
    {0, -1, 0, 0, 0.000000000000000, 0.000000000000000},
    {0, -1, 0, 1, 0.000000000000000, 0.000000000000000},
    {0, -1, 0, 2, 0.661266183461805, 0.422966208408802},
    {0, -1, 1, -1, 0.478155746088161, -1.04916052873278},
    {0, -1, 1, 0, 0.599070117367796, -0.599070117367796},
    {0, -1, 1, 1, 0.778004078788958, -0.188411067988680},
    {0, -1, 1, 2, 0.985872907297986, 0.178866979357132},
    {0, -1, 2, -1, 0.897764105638205, -1.13815978557677},
    {0, -1, 2, 0, 1.01005159361958, -0.742646422399778},
    {0, -1, 2, 1, 1.15631976909117, -0.363823969691055},
    {0, -1, 2, 2, 1.32391495927282, -0.0126420344317752},
    {0, 0, -1, -1, 0.000000000000000, 0.000000000000000},
    {0, 0, -1, 0, 0.000000000000000, 0.000000000000000},
    {0, 0, -1, 1, 0.000000000000000, 0.000000000000000},
    {0, 0, -1, 2, 0.000000000000000, 0.000000000000000},
    {0, 0, 0, -1, 0.000000000000000, 0.000000000000000},
    {0, 0, 0, 0, 0.000000000000000, 0.000000000000000},
    {0, 0, 0, 1, 0.000000000000000, 0.000000000000000},
    {0, 0, 0, 2, 0.000000000000000, 0.000000000000000},
    {0, 0, 1, -1, 0.000000000000000, 0.000000000000000},
    {0, 0, 1, 0, 0.000000000000000, 0.000000000000000},
    {0, 0, 1, 1, 0.000000000000000, 0.000000000000000},
    {0, 0, 1, 2, 0.000000000000000, 0.000000000000000},
    {0, 0, 2, -1, 0.000000000000000, 0.000000000000000},
    {0, 0, 2, 0, 0.000000000000000, 0.000000000000000},
    {0, 0, 2, 1, 0.000000000000000, 0.000000000000000},
    {0, 0, 2, 2, 0.000000000000000, 0.000000000000000},
    {0, 1, -1, -1, -0.778004078788958, 0.188411067988680},
    {0, 1, -1, 0, -0.599070117367796, 0.599070117367796},
    {0, 1, -1, 1, -0.478155746088161, 1.04916052873278},
    {0, 1, -1, 2, -0.420983902077155, 1.47839688785392},
    {0, 1, 0, -1, 0.000000000000000, 0.000000000000000},
    {0, 1, 0, 0, 0.000000000000000, 0.000000000000000},
    {0, 1, 0, 1, 0.000000000000000, 1.00000000000000},
    {0, 1, 0, 2, 0.000000000000000, 1.45679103104691},
    {0, 1, 1, -1, 0.778004078788958, 0.188411067988680},
    {0, 1, 1, 0, 0.599070117367796, 0.599070117367796},
    {0, 1, 1, 1, 0.478155746088161, 1.04916052873278},
    {0, 1, 1, 2, 0.420983902077155, 1.47839688785392},
    {0, 1, 2, -1, 1.15631976909117, 0.363823969691055},
    {0, 1, 2, 0, 1.01005159361958, 0.742646422399778},
    {0, 1, 2, 1, 0.897764105638205, 1.13815978557677},
    {0, 1, 2, 2, 0.820905313474926, 1.53147158277780},
    {0, 2, -1, -1, -0.966415146777638, 0.589593010800278},
    {0, 2, -1, 0, -0.742646422399778, 1.01005159361958},
    {0, 2, -1, 1, -0.571004782644619, 1.52731627482094},
    {0, 2, -1, 2, -0.493004461502931, 2.02900451838781},
    {0, 2, 0, -1, 0.661266183461805, 0.422966208408802},
    {0, 2, 0, 0, 0.000000000000000, 0.000000000000000},
    {0, 2, 0, 1, 0.000000000000000, 1.45679103104691},
    {0, 2, 0, 2, 0.000000000000000, 2.00000000000000},
    {0, 2, 1, -1, 0.966415146777638, 0.589593010800278},
    {0, 2, 1, 0, 0.742646422399778, 1.01005159361958},
    {0, 2, 1, 1, 0.571004782644619, 1.52731627482094},
    {0, 2, 1, 2, 0.493004461502931, 2.02900451838781},
    {0, 2, 2, -1, 1.37110999239961, 0.777111977967075},
    {0, 2, 2, 0, 1.19814023473559, 1.19814023473559},
    {0, 2, 2, 1, 1.05542091981433, 1.64623191253177},
    {0, 2, 2, 2, 0.956311492176322, 2.09832105746556},
    {1, -1, -1, -1, 0.000000000000000, -1.19814023473559},
    {1, -1, -1, 0, -0.188411067988680, -0.778004078788958},
    {1, -1, -1, 1, 0.000000000000000, 0.000000000000000},
    {1, -1, -1, 2, 0.574659643809835, 0.810208383866421},
    {1, -1, 0, -1, 0.478155746088161, -1.04916052873278},
    {1, -1, 0, 0, 0.000000000000000, 0.000000000000000},
    {1, -1, 0, 1, 0.778004078788958, 0.188411067988680},
    {1, -1, 0, 2, 0.966415146777638, 0.589593010800278},
    {1, -1, 1, -1, 1.00000000000000, -1.00000000000000},
    {1, -1, 1, 0, 1.04916052873278, -0.478155746088161},
    {1, -1, 1, 1, 1.19814023473559, 0.000000000000000},
    {1, -1, 1, 2, 1.35980258211696, 0.412918513270561},
    {1, -1, 2, -1, 1.47134936286465, -1.02005412633766},
    {1, -1, 2, 0, 1.52731627482094, -0.571004782644619},
    {1, -1, 2, 1, 1.62780548487271, -0.136827548397369},
    {1, -1, 2, 2, 1.75269801601936, 0.267405171219803},
    {1, 0, -1, -1, 0.188411067988680, -0.778004078788958},
    {1, 0, -1, 0, 0.000000000000000, 0.000000000000000},
    {1, 0, -1, 1, 0.188411067988680, 0.778004078788958},
    {1, 0, -1, 2, 0.363823969691055, 1.15631976909117},
    {1, 0, 0, -1, 0.599070117367796, -0.599070117367796},
    {1, 0, 0, 0, 0.000000000000000, 0.000000000000000},
    {1, 0, 0, 1, 0.599070117367796, 0.599070117367796},
    {1, 0, 0, 2, 0.742646422399778, 1.01005159361958},
    {1, 0, 1, -1, 1.04916052873278, -0.478155746088161},
    {1, 0, 1, 0, 1.00000000000000, 0.000000000000000},
    {1, 0, 1, 1, 1.04916052873278, 0.478155746088161},
    {1, 0, 1, 2, 1.13815978557677, 0.897764105638205},
    {1, 0, 2, -1, 1.47839688785392, -0.420983902077155},
    {1, 0, 2, 0, 1.45679103104691, 0.000000000000000},
    {1, 0, 2, 1, 1.47839688785392, 0.420983902077155},
    {1, 0, 2, 2, 1.53147158277780, 0.820905313474926},
    {1, 1, -1, -1, 0.000000000000000, 0.000000000000000},
    {1, 1, -1, 0, -0.188411067988680, 0.778004078788958},
    {1, 1, -1, 1, 0.000000000000000, 1.19814023473559},
    {1, 1, -1, 2, 0.136827548397369, 1.62780548487271},
    {1, 1, 0, -1, 0.778004078788958, -0.188411067988680},
    {1, 1, 0, 0, 0.000000000000000, 0.000000000000000},
    {1, 1, 0, 1, 0.478155746088161, 1.04916052873278},
    {1, 1, 0, 2, 0.571004782644619, 1.52731627482094},
    {1, 1, 1, -1, 1.19814023473559, 0.000000000000000},
    {1, 1, 1, 0, 1.04916052873278, 0.478155746088161},
    {1, 1, 1, 1, 1.00000000000000, 1.00000000000000},
    {1, 1, 1, 2, 1.02005412633766, 1.47134936286465},
    {1, 1, 2, -1, 1.62780548487271, 0.136827548397369},
    {1, 1, 2, 0, 1.52731627482094, 0.571004782644619},
    {1, 1, 2, 1, 1.47134936286465, 1.02005412633766},
    {1, 1, 2, 2, 1.45679103104691, 1.45679103104691},
    {1, 2, -1, -1, -0.574659643809835, 0.810208383866421},
    {1, 2, -1, 0, -0.363823969691055, 1.15631976909117},
    {1, 2, -1, 1, -0.136827548397369, 1.62780548487271},
    {1, 2, -1, 2, 0.000000000000000, 2.11638793788003},
    {1, 2, 0, -1, 0.985872907297986, 0.178866979357132},
    {1, 2, 0, 0, 0.000000000000000, 0.000000000000000},
    {1, 2, 0, 1, 0.420983902077155, 1.47839688785392},
    {1, 2, 0, 2, 0.493004461502931, 2.02900451838781},
    {1, 2, 1, -1, 1.35980258211696, 0.412918513270561},
    {1, 2, 1, 0, 1.13815978557677, 0.897764105638205},
    {1, 2, 1, 1, 1.02005412633766, 1.47134936286465},
    {1, 2, 1, 2, 1.00000000000000, 2.00000000000000},
    {1, 2, 2, -1, 1.79721035210339, 0.599070117367796},
    {1, 2, 2, 0, 1.64623191253177, 1.05542091981433},
    {1, 2, 2, 1, 1.54030226799894, 1.54030226799894},
    {1, 2, 2, 2, 1.48529284479956, 2.02010318723916},
    {2, -1, -1, -1, 0.412918513270561, -1.35980258211696},
    {2, -1, -1, 0, 0.178866979357132, -0.985872907297986},
    {2, -1, -1, 1, 0.810208383866421, 0.574659643809835},
    {2, -1, -1, 2, 0.963366302386887, 0.963366302386887},
    {2, -1, 0, -1, 0.897764105638205, -1.13815978557677},
    {2, -1, 0, 0, 0.000000000000000, 0.000000000000000},
    {2, -1, 0, 1, 1.15631976909117, 0.363823969691055},
    {2, -1, 0, 2, 1.37110999239961, 0.777111977967075},
    {2, -1, 1, -1, 1.47134936286465, -1.02005412633766},
    {2, -1, 1, 0, 1.47839688785392, -0.420983902077155},
    {2, -1, 1, 1, 1.62780548487271, 0.136827548397369},
    {2, -1, 1, 2, 1.79721035210339, 0.599070117367796},
    {2, -1, 2, -1, 2.00000000000000, -1.00000000000000},
    {2, -1, 2, 0, 2.02900451838781, -0.493004461502931},
    {2, -1, 2, 1, 2.11638793788003, 0.000000000000000},
    {2, -1, 2, 2, 2.23571522629432, 0.455159607692816},
    {2, 0, -1, -1, 0.589593010800278, -0.966415146777638},
    {2, 0, -1, 0, 0.422966208408802, 0.661266183461805},
    {2, 0, -1, 1, 0.589593010800278, 0.966415146777638},
    {2, 0, -1, 2, 0.777111977967075, 1.37110999239961},
    {2, 0, 0, -1, 1.01005159361958, -0.742646422399778},
    {2, 0, 0, 0, 0.000000000000000, 0.000000000000000},
    {2, 0, 0, 1, 1.01005159361958, 0.742646422399778},
    {2, 0, 0, 2, 1.19814023473559, 1.19814023473559},
    {2, 0, 1, -1, 1.52731627482094, -0.571004782644619},
    {2, 0, 1, 0, 1.45679103104691, 0.000000000000000},
    {2, 0, 1, 1, 1.52731627482094, 0.571004782644619},
    {2, 0, 1, 2, 1.64623191253177, 1.05542091981433},
    {2, 0, 2, -1, 2.02900451838781, -0.493004461502931},
    {2, 0, 2, 0, 2.00000000000000, 0.000000000000000},
    {2, 0, 2, 1, 2.02900451838781, 0.493004461502931},
    {2, 0, 2, 2, 2.09832105746556, 0.956311492176322},
    {2, 1, -1, -1, 0.810208383866421, -0.574659643809835},
    {2, 1, -1, 0, 0.178866979357132, 0.985872907297986},
    {2, 1, -1, 1, 0.412918513270561, 1.35980258211696},
    {2, 1, -1, 2, 0.599070117367796, 1.79721035210339},
    {2, 1, 0, -1, 1.15631976909117, -0.363823969691055},
    {2, 1, 0, 0, 0.000000000000000, 0.000000000000000},
    {2, 1, 0, 1, 0.897764105638205, 1.13815978557677},
    {2, 1, 0, 2, 1.05542091981433, 1.64623191253177},
    {2, 1, 1, -1, 1.62780548487271, -0.136827548397369},
    {2, 1, 1, 0, 1.47839688785392, 0.420983902077155},
    {2, 1, 1, 1, 1.47134936286465, 1.02005412633766},
    {2, 1, 1, 2, 1.54030226799894, 1.54030226799894},
    {2, 1, 2, -1, 2.11638793788003, 0.000000000000000},
    {2, 1, 2, 0, 2.02900451838781, 0.493004461502931},
    {2, 1, 2, 1, 2.00000000000000, 1.00000000000000},
    {2, 1, 2, 2, 2.02010318723916, 1.48529284479956},
    {2, 2, -1, -1, 1.08423239187061, -0.238299975053003},
    {2, 2, -1, 0, -0.0126420344317752, 1.32391495927282},
    {2, 2, -1, 1, 0.267405171219803, 1.75269801601936},
    {2, 2, -1, 2, 0.455159607692816, 2.23571522629432},
    {2, 2, 0, -1, 1.32391495927282, -0.0126420344317752},
    {2, 2, 0, 0, 0.000000000000000, 0.000000000000000},
    {2, 2, 0, 1, 0.820905313474926, 1.53147158277780},
    {2, 2, 0, 2, 0.956311492176322, 2.09832105746556},
    {2, 2, 1, -1, 1.75269801601936, 0.267405171219803},
    {2, 2, 1, 0, 1.53147158277780, 0.820905313474926},
    {2, 2, 1, 1, 1.45679103104691, 1.45679103104691},
    {2, 2, 1, 2, 1.48529284479956, 2.02010318723916},
    {2, 2, 2, -1, 2.23571522629432, 0.455159607692816},
    {2, 2, 2, 0, 2.09832105746556, 0.956311492176322},
    {2, 2, 2, 1, 2.02010318723916, 1.48529284479956},
    {2, 2, 2, 2, 2.00000000000000, 2.00000000000000},
};

TEST_FUNCTION_START(acb_agm, state)
{
    slong iter;

    /* test particular values against table */
    {
        acb_t x, y, r, s;

        acb_init(x);
        acb_init(y);
        acb_init(r);
        acb_init(s);

        for (iter = 0; iter < NUM_TESTS; iter++)
        {
            acb_set_d_d(x, agm_testdata[iter][0], agm_testdata[iter][1]);
            acb_set_d_d(y, agm_testdata[iter][2], agm_testdata[iter][3]);
            acb_set_d_d(s, agm_testdata[iter][4], agm_testdata[iter][5]);
            mag_set_d(arb_radref(acb_realref(s)), 1e-13);
            mag_set_d(arb_radref(acb_imagref(s)), 1e-13);

            acb_agm(r, x, y, 64);

            if (!acb_overlaps(r, s))
            {
                flint_printf("FAIL\n\n");
                flint_printf("x = "); acb_printd(x, 15); flint_printf("\n\n");
                flint_printf("y = "); acb_printd(y, 15); flint_printf("\n\n");
                flint_printf("r = "); acb_printd(r, 15); flint_printf("\n\n");
                flint_printf("s = "); acb_printd(s, 15); flint_printf("\n\n");
                flint_abort();
            }
    }

        acb_clear(x);
        acb_clear(y);
        acb_clear(r);
        acb_clear(s);
    }

    /* self-consistency test */
    for (iter = 0; iter < 1000 * 0.1 * flint_test_multiplier(); iter++)
    {
        acb_t m1, m2;
        acb_t x1, x2, y1, y2, t;
        slong prec1, prec2;

        prec1 = 2 + n_randint(state, 200);
        prec2 = 2 + n_randint(state, 200);

        acb_init(x1);
        acb_init(x2);
        acb_init(y1);
        acb_init(y2);
        acb_init(m1);
        acb_init(m2);
        acb_init(t);

        acb_randtest(x1, state, prec1, 1 + n_randint(state, 100));
        acb_randtest(y1, state, prec1, 1 + n_randint(state, 100));
        acb_randtest(m1, state, prec1, 1 + n_randint(state, 100));
        acb_randtest(m2, state, prec1, 1 + n_randint(state, 100));

        if (n_randint(state, 2))
        {
            acb_randtest(t, state, prec2, 1 + n_randint(state, 200));
            acb_mul(y1, x1, t, prec1);
        }

        if (n_randint(state, 2))
            acb_swap(x1, y1);

        if (n_randint(state, 2))
        {
            acb_set(x2, x1);
        }
        else
        {
            acb_randtest(t, state, prec2, 1 + n_randint(state, 200));
            acb_add(x2, x1, t, prec2);
            acb_sub(x2, x2, t, prec2);
        }

        if (n_randint(state, 2))
        {
            acb_set(y2, y1);
        }
        else
        {
            acb_randtest(t, state, prec2, 1 + n_randint(state, 200));
            acb_add(y2, y1, t, prec2);
            acb_sub(y2, y2, t, prec2);
        }

        acb_agm(m1, x1, y1, prec1);
        acb_agm(m2, x2, y2, prec2);

        if (!acb_overlaps(m1, m2))
        {
            flint_printf("FAIL (overlap)\n\n");
            flint_printf("iter = %wd, prec1 = %wd, prec2 = %wd\n\n", iter, prec1, prec2);

            flint_printf("x1 = "); acb_printd(x1, 30); flint_printf("\n\n");
            flint_printf("y1 = "); acb_printd(y1, 30); flint_printf("\n\n");
            flint_printf("x2 = "); acb_printd(x2, 30); flint_printf("\n\n");
            flint_printf("y2 = "); acb_printd(y2, 30); flint_printf("\n\n");
            flint_printf("m1 = "); acb_printd(m1, 30); flint_printf("\n\n");
            flint_printf("m2 = "); acb_printd(m2, 30); flint_printf("\n\n");
            flint_abort();
        }

        acb_div(t, x1, y1, prec1);
        if (acb_is_finite(t) && (!acb_is_real(t) || !arb_is_negative(acb_realref(t))))
        {
            if (n_randint(state, 2))
            {
                acb_div(t, x1, y1, prec1);
                acb_agm1(t, t, prec1);
                acb_mul(t, t, y1, prec1);
            }
            else
            {
                acb_div(t, y1, x1, prec1);
                acb_agm1(t, t, prec1);
                acb_mul(t, t, x1, prec1);
            }

            if (!acb_overlaps(t, m1))
            {
                flint_printf("FAIL (overlap 2)\n\n");
                flint_printf("iter = %wd, prec1 = %wd, prec2 = %wd\n\n", iter, prec1, prec2);

                flint_printf("x1 = "); acb_printd(x1, 30); flint_printf("\n\n");
                flint_printf("y1 = "); acb_printd(y1, 30); flint_printf("\n\n");
                flint_printf("m1 = "); acb_printd(m1, 30); flint_printf("\n\n");
                flint_printf("t = "); acb_printd(t, 30); flint_printf("\n\n");
                flint_abort();
            }
        }

        acb_clear(x1);
        acb_clear(x2);
        acb_clear(y1);
        acb_clear(y2);
        acb_clear(m1);
        acb_clear(m2);
        acb_clear(t);
    }

    TEST_FUNCTION_END(state);
}
#undef NUM_TESTS