void _arb_poly_revert_series_lagrange_fast(arb_ptr Qinv, arb_srcptr Q, long Qlen, long n, long prec) { long i, j, k, m; arb_ptr R, S, T, tmp; arb_t t; if (n <= 2) { if (n >= 1) arb_zero(Qinv); if (n == 2) arb_inv(Qinv + 1, Q + 1, prec); return; } m = n_sqrt(n); arb_init(t); R = _arb_vec_init((n - 1) * m); S = _arb_vec_init(n - 1); T = _arb_vec_init(n - 1); arb_zero(Qinv); arb_inv(Qinv + 1, Q + 1, prec); _arb_poly_inv_series(Ri(1), Q + 1, FLINT_MIN(Qlen, n) - 1, n - 1, prec); for (i = 2; i <= m; i++) _arb_poly_mullow(Ri(i), Ri((i + 1) / 2), n - 1, Ri(i / 2), n - 1, n - 1, prec); for (i = 2; i < m; i++) arb_div_ui(Qinv + i, Ri(i) + i - 1, i, prec); _arb_vec_set(S, Ri(m), n - 1); for (i = m; i < n; i += m) { arb_div_ui(Qinv + i, S + i - 1, i, prec); for (j = 1; j < m && i + j < n; j++) { arb_mul(t, S + 0, Ri(j) + i + j - 1, prec); for (k = 1; k <= i + j - 1; k++) arb_addmul(t, S + k, Ri(j) + i + j - 1 - k, prec); arb_div_ui(Qinv + i + j, t, i + j, prec); } if (i + 1 < n) { _arb_poly_mullow(T, S, n - 1, Ri(m), n - 1, n - 1, prec); tmp = S; S = T; T = tmp; } } arb_clear(t); _arb_vec_clear(R, (n - 1) * m); _arb_vec_clear(S, n - 1); _arb_vec_clear(T, n - 1); }
int f_pol(arb_t max, const arb_t t, params_t * p, slong prec) { slong k; acb_t z; arb_t tmp; acb_init(z); arb_init(tmp); arb_one(max); for (k = 0; k < p->len; k++) { acb_sub_arb(z, p->z + k, t, prec); acb_abs(tmp, z, prec); if (arb_contains_zero(tmp)) return 0; arb_mul(max, max, tmp, prec); } arb_inv(max, max, prec); arb_clear(tmp); acb_clear(z); return 1; }
void arb_sech(arb_t res, const arb_t x, slong prec) { if (arf_cmpabs_2exp_si(arb_midref(x), 0) > 0) { arb_t t; arb_init(t); if (arf_sgn(arb_midref(x)) > 0) { arb_neg(t, x); arb_exp(t, t, prec + 4); } else { arb_exp(t, x, prec + 4); } arb_mul(res, t, t, prec + 4); arb_add_ui(res, res, 1, prec + 4); arb_div(res, t, res, prec); arb_mul_2exp_si(res, res, 1); arb_clear(t); } else { arb_cosh(res, x, prec + 4); arb_inv(res, res, prec); } }
void custom_rate_mixture_get_prob(arb_t prob, const custom_rate_mixture_t x, slong idx, slong prec) { if (x->mode == RATE_MIXTURE_UNDEFINED) { flint_fprintf(stderr, "internal error: undefined rate mixture\n"); abort(); } else if (x->mode == RATE_MIXTURE_NONE) { arb_one(prob); } else if (x->mode == RATE_MIXTURE_UNIFORM) { /* * This code branch involves a division that could * unnecessarily lose exactness in some situations. */ arb_set_si(prob, x->n); arb_inv(prob, prob, prec); } else if (x->mode == RATE_MIXTURE_CUSTOM) { arb_set_d(prob, x->prior[idx]); } else { flint_fprintf(stderr, "internal error: " "unrecognized rate mixture mode\n"); abort(); } }
int main() { slong iter; flint_rand_t state; flint_printf("csch...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 1000 * arb_test_multiplier(); iter++) { arb_t x, a, b; slong prec1, prec2; prec1 = 2 + n_randint(state, 200); prec2 = prec1 + 30; arb_init(x); arb_init(a); arb_init(b); arb_randtest_special(x, state, 1 + n_randint(state, 300), 100); arb_randtest_special(a, state, 1 + n_randint(state, 300), 100); arb_randtest_special(b, state, 1 + n_randint(state, 300), 100); if (n_randint(state, 2)) { arb_csch(a, x, prec1); } else { arb_set(a, x); arb_csch(a, a, prec1); } arb_sinh(b, x, prec2); arb_inv(b, b, prec2); /* check consistency */ if (!arb_overlaps(a, b)) { flint_printf("FAIL: overlap\n\n"); flint_printf("x = "); arb_printn(x, 20, 0); flint_printf("\n\n"); flint_printf("a = "); arb_printn(a, 20, 0); flint_printf("\n\n"); flint_printf("b = "); arb_printn(b, 20, 0); flint_printf("\n\n"); flint_abort(); } arb_clear(x); arb_clear(a); arb_clear(b); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int f_1x2(arb_t max, const arb_t t, params_t * p, slong prec) { arb_mul(max, t, t, prec); arb_add_si(max, max, 1, prec); arb_inv(max, max, prec); return 1; }
int main() { slong iter; flint_rand_t state; flint_printf("rsqrt...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 100000; iter++) { arb_t a, b, c; slong prec = 2 + n_randint(state, 200); arb_init(a); arb_init(b); arb_init(c); arb_randtest(a, state, 1 + n_randint(state, 200), 10); arb_rsqrt(b, a, prec); arb_inv(c, b, prec); arb_mul(c, c, c, prec); if (!arb_contains(c, a)) { flint_printf("FAIL: containment\n\n"); flint_printf("a = "); arb_print(a); flint_printf("\n\n"); flint_printf("b = "); arb_print(b); flint_printf("\n\n"); flint_printf("c = "); arb_print(c); flint_printf("\n\n"); abort(); } arb_rsqrt(a, a, prec); if (!arb_equal(a, b)) { flint_printf("FAIL: aliasing\n\n"); abort(); } arb_clear(a); arb_clear(b); arb_clear(c); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
static void bound_I(arb_ptr I, const arb_t A, const arb_t B, const arb_t C, slong len, slong wp) { slong k; arb_t D, Dk, L, T, Bm1; arb_init(D); arb_init(Dk); arb_init(Bm1); arb_init(T); arb_init(L); arb_sub_ui(Bm1, B, 1, wp); arb_one(L); /* T = 1 / (A^Bm1 * Bm1) */ arb_inv(T, A, wp); arb_pow(T, T, Bm1, wp); arb_div(T, T, Bm1, wp); if (len > 1) { arb_log(D, A, wp); arb_add(D, D, C, wp); arb_mul(D, D, Bm1, wp); arb_set(Dk, D); } for (k = 0; k < len; k++) { if (k > 0) { arb_mul_ui(L, L, k, wp); arb_add(L, L, Dk, wp); arb_mul(Dk, Dk, D, wp); } arb_mul(I + k, L, T, wp); arb_div(T, T, Bm1, wp); } arb_clear(D); arb_clear(Dk); arb_clear(Bm1); arb_clear(T); arb_clear(L); }
int f_aj(arb_t m, const arb_t t, params_t * p, slong prec) { slong k; acb_t z, zu; arb_t abs; arb_init(abs); acb_init(z); acb_init(zu); arb_const_pi(abs, prec); arb_mul_2exp_si(abs, abs, -2); /* Pi/4 */ arb_set(acb_realref(z), t); arb_set(acb_imagref(z), abs); acb_sinh(z, z, prec); arb_mul_2exp_si(abs, abs, 1); /* Pi/2 */ acb_mul_arb(z, z, abs, prec); acb_tanh(z, z, prec); arb_one(m); for (k = 0; k < p->len; k++) { acb_sub(zu, z, p->z + k, prec); if (acb_contains_zero(zu)) { arb_clear(abs); acb_clear(zu); acb_clear(z); return 0; } acb_abs(abs, zu, prec); arb_mul(m, m, abs, prec); } arb_inv(m, m, prec); arb_clear(abs); acb_clear(zu); acb_clear(z); return 1; }
void _arb_poly_inv_series(arb_ptr Qinv, arb_srcptr Q, slong Qlen, slong len, slong prec) { arb_inv(Qinv, Q, prec); if (Qlen == 1) { _arb_vec_zero(Qinv + 1, len - 1); } else if (len == 2) { arb_div(Qinv + 1, Qinv, Q, prec); arb_mul(Qinv + 1, Qinv + 1, Q + 1, prec); arb_neg(Qinv + 1, Qinv + 1); } else { slong Qnlen, Wlen, W2len; arb_ptr W; W = _arb_vec_init(len); NEWTON_INIT(1, len) NEWTON_LOOP(m, n) Qnlen = FLINT_MIN(Qlen, n); Wlen = FLINT_MIN(Qnlen + m - 1, n); W2len = Wlen - m; MULLOW(W, Q, Qnlen, Qinv, m, Wlen, prec); MULLOW(Qinv + m, Qinv, m, W + m, W2len, n - m, prec); _arb_vec_neg(Qinv + m, Qinv + m, n - m); NEWTON_END_LOOP NEWTON_END _arb_vec_clear(W, len); } }
int main() { slong iter; flint_rand_t state; flint_printf("euler_product_real_ui...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 3000 * arb_test_multiplier(); iter++) { arb_t res1, res2; ulong s; slong prec1, prec2, accuracy; int choice, reciprocal1, reciprocal2; if (iter % 10 == 0) { s = n_randtest(state); prec1 = 2 + n_randint(state, 300); prec2 = 2 + n_randint(state, 300); } else { s = 6 + n_randint(state, 1 << n_randint(state, 12)); prec1 = 2 + n_randint(state, 12 * s); prec2 = 2 + n_randint(state, 12 * s); } if (n_randint(state, 30) == 0) prec1 = 2 + n_randint(state, 4000); choice = n_randint(state, 7); reciprocal1 = n_randint(state, 2); reciprocal2 = n_randint(state, 2); arb_init(res1); arb_init(res2); arb_randtest(res1, state, 200, 100); _acb_dirichlet_euler_product_real_ui(res1, s, chi[choice] + 1, chi[choice][0], reciprocal1, prec1); _acb_dirichlet_euler_product_real_ui(res2, s, chi[choice] + 1, chi[choice][0], reciprocal2, prec2); if (reciprocal1 != reciprocal2) arb_inv(res2, res2, prec2); if (!arb_overlaps(res1, res2)) { flint_printf("FAIL: overlap\n\n"); flint_printf("s = %wu\n\n", s); flint_printf("chi: %d\n", choice); flint_printf("res1 = "); arb_printd(res1, prec1 / 3.33); flint_printf("\n\n"); flint_printf("res2 = "); arb_printd(res2, prec2 / 3.33); flint_printf("\n\n"); abort(); } if (s >= 6 && prec1 < 2 * s * log(s)) { accuracy = arb_rel_accuracy_bits(res1); if (accuracy < prec1 - 4) { flint_printf("FAIL: accuracy = %wd, prec = %wd\n\n", accuracy, prec1); flint_printf("res1 = "); arb_printd(res1, prec1 / 3.33); flint_printf("\n\n"); abort(); } } if (s == 10) { arf_set_d(arb_midref(res2), L10[choice]); mag_set_d(arb_radref(res2), 1e-15); if (reciprocal1) arb_inv(res2, res2, 53); if (!arb_overlaps(res1, res2)) { flint_printf("FAIL: overlap (2)\n\n"); flint_printf("s = %wu\n\n", s); flint_printf("chi: %d\n", choice); flint_printf("res1 = "); arb_printd(res1, prec1 / 3.33); flint_printf("\n\n"); flint_printf("res2 = "); arb_printd(res2, prec2 / 3.33); flint_printf("\n\n"); abort(); } } arb_clear(res1); arb_clear(res2); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
void _arb_poly_inv_series(arb_ptr Qinv, arb_srcptr Q, slong Qlen, slong len, slong prec) { Qlen = FLINT_MIN(Qlen, len); arb_inv(Qinv, Q, prec); if (Qlen == 1) { _arb_vec_zero(Qinv + 1, len - 1); } else if (len == 2) { arb_mul(Qinv + 1, Qinv, Qinv, prec); arb_mul(Qinv + 1, Qinv + 1, Q + 1, prec); arb_neg(Qinv + 1, Qinv + 1); } else { slong i, j, blen; /* The basecase algorithm is faster for much larger Qlen or len than this, but unfortunately also much less numerically stable. */ if (Qlen == 2 || len <= 8) blen = len; else blen = FLINT_MIN(len, 4); for (i = 1; i < blen; i++) { arb_mul(Qinv + i, Q + 1, Qinv + i - 1, prec); for (j = 2; j < FLINT_MIN(i + 1, Qlen); j++) arb_addmul(Qinv + i, Q + j, Qinv + i - j, prec); if (!arb_is_one(Qinv)) arb_mul(Qinv + i, Qinv + i, Qinv, prec); arb_neg(Qinv + i, Qinv + i); } if (len > blen) { slong Qnlen, Wlen, W2len; arb_ptr W; W = _arb_vec_init(len); NEWTON_INIT(blen, len) NEWTON_LOOP(m, n) Qnlen = FLINT_MIN(Qlen, n); Wlen = FLINT_MIN(Qnlen + m - 1, n); W2len = Wlen - m; MULLOW(W, Q, Qnlen, Qinv, m, Wlen, prec); MULLOW(Qinv + m, Qinv, m, W + m, W2len, n - m, prec); _arb_vec_neg(Qinv + m, Qinv + m, n - m); NEWTON_END_LOOP NEWTON_END _arb_vec_clear(W, len); } } }
void _arb_poly_zeta_series(arb_ptr res, arb_srcptr h, long hlen, const arb_t a, int deflate, long len, long prec) { long i; acb_t cs, ca; acb_ptr z; arb_ptr t, u; if (arb_contains_nonpositive(a)) { _arb_vec_indeterminate(res, len); return; } hlen = FLINT_MIN(hlen, len); z = _acb_vec_init(len); t = _arb_vec_init(len); u = _arb_vec_init(len); acb_init(cs); acb_init(ca); /* use reflection formula */ if (arf_sgn(arb_midref(h)) < 0 && arb_is_one(a)) { /* zeta(s) = (2*pi)**s * sin(pi*s/2) / pi * gamma(1-s) * zeta(1-s) */ arb_t pi; arb_ptr f, s1, s2, s3, s4; arb_init(pi); f = _arb_vec_init(2); s1 = _arb_vec_init(len); s2 = _arb_vec_init(len); s3 = _arb_vec_init(len); s4 = _arb_vec_init(len); arb_const_pi(pi, prec); /* s1 = (2*pi)**s */ arb_mul_2exp_si(pi, pi, 1); _arb_poly_pow_cpx(s1, pi, h, len, prec); arb_mul_2exp_si(pi, pi, -1); /* s2 = sin(pi*s/2) / pi */ arb_set(f, h); arb_one(f + 1); arb_mul_2exp_si(f, f, -1); arb_mul_2exp_si(f + 1, f + 1, -1); _arb_poly_sin_pi_series(s2, f, 2, len, prec); _arb_vec_scalar_div(s2, s2, len, pi, prec); /* s3 = gamma(1-s) */ arb_sub_ui(f, h, 1, prec); arb_neg(f, f); arb_set_si(f + 1, -1); _arb_poly_gamma_series(s3, f, 2, len, prec); /* s4 = zeta(1-s) */ arb_sub_ui(f, h, 1, prec); arb_neg(f, f); acb_set_arb(cs, f); acb_one(ca); _acb_poly_zeta_cpx_series(z, cs, ca, 0, len, prec); for (i = 0; i < len; i++) arb_set(s4 + i, acb_realref(z + i)); for (i = 1; i < len; i += 2) arb_neg(s4 + i, s4 + i); _arb_poly_mullow(u, s1, len, s2, len, len, prec); _arb_poly_mullow(s1, s3, len, s4, len, len, prec); _arb_poly_mullow(t, u, len, s1, len, len, prec); /* add 1/(1-(s+t)) = 1/(1-s) + t/(1-s)^2 + ... */ if (deflate) { arb_sub_ui(u, h, 1, prec); arb_neg(u, u); arb_inv(u, u, prec); for (i = 1; i < len; i++) arb_mul(u + i, u + i - 1, u, prec); _arb_vec_add(t, t, u, len, prec); } arb_clear(pi); _arb_vec_clear(f, 2); _arb_vec_clear(s1, len); _arb_vec_clear(s2, len); _arb_vec_clear(s3, len); _arb_vec_clear(s4, len); } else { acb_set_arb(cs, h); acb_set_arb(ca, a); _acb_poly_zeta_cpx_series(z, cs, ca, deflate, len, prec); for (i = 0; i < len; i++) arb_set(t + i, acb_realref(z + i)); } /* compose with nonconstant part */ arb_zero(u); _arb_vec_set(u + 1, h + 1, hlen - 1); _arb_poly_compose_series(res, t, len, u, hlen, len, prec); _acb_vec_clear(z, len); _arb_vec_clear(t, len); _arb_vec_clear(u, len); acb_init(cs); acb_init(ca); }
void acb_inv(acb_t res, const acb_t z, slong prec) { mag_t am, bm; slong hprec; #define a arb_midref(acb_realref(z)) #define b arb_midref(acb_imagref(z)) #define x arb_radref(acb_realref(z)) #define y arb_radref(acb_imagref(z)) /* choose precision for the floating-point approximation of a^2+b^2 so that the double rounding result in less than 2 ulp error; also use at least MAG_BITS bits since the value will be recycled for error bounds */ hprec = FLINT_MAX(prec + 3, MAG_BITS); if (arb_is_zero(acb_imagref(z))) { arb_inv(acb_realref(res), acb_realref(z), prec); arb_zero(acb_imagref(res)); return; } if (arb_is_zero(acb_realref(z))) { arb_inv(acb_imagref(res), acb_imagref(z), prec); arb_neg(acb_imagref(res), acb_imagref(res)); arb_zero(acb_realref(res)); return; } if (!acb_is_finite(z)) { acb_indeterminate(res); return; } if (mag_is_zero(x) && mag_is_zero(y)) { int inexact; arf_t a2b2; arf_init(a2b2); inexact = arf_sosq(a2b2, a, b, hprec, ARF_RND_DOWN); if (arf_is_special(a2b2)) { acb_indeterminate(res); } else { _arb_arf_div_rounded_den(acb_realref(res), a, a2b2, inexact, prec); _arb_arf_div_rounded_den(acb_imagref(res), b, a2b2, inexact, prec); arf_neg(arb_midref(acb_imagref(res)), arb_midref(acb_imagref(res))); } arf_clear(a2b2); return; } mag_init(am); mag_init(bm); /* first bound |a|-x, |b|-y */ arb_get_mag_lower(am, acb_realref(z)); arb_get_mag_lower(bm, acb_imagref(z)); if ((mag_is_zero(am) && mag_is_zero(bm))) { acb_indeterminate(res); } else { /* The propagated error in the real part is given exactly by (a+x')/((a+x')^2+(b+y'))^2 - a/(a^2+b^2) = P / Q, P = [(b^2-a^2) x' - a (x'^2+y'^2 + 2y'b)] Q = [(a^2+b^2)((a+x')^2+(b+y')^2)] where |x'| <= x and |y'| <= y, and analogously for the imaginary part. */ mag_t t, u, v, w; arf_t a2b2; int inexact; mag_init(t); mag_init(u); mag_init(v); mag_init(w); arf_init(a2b2); inexact = arf_sosq(a2b2, a, b, hprec, ARF_RND_DOWN); /* compute denominator */ /* t = (|a|-x)^2 + (|b|-x)^2 (lower bound) */ mag_mul_lower(t, am, am); mag_mul_lower(u, bm, bm); mag_add_lower(t, t, u); /* u = a^2 + b^2 (lower bound) */ arf_get_mag_lower(u, a2b2); /* t = ((|a|-x)^2 + (|b|-x)^2)(a^2 + b^2) (lower bound) */ mag_mul_lower(t, t, u); /* compute numerator */ /* real: |a^2-b^2| x + |a| ((x^2 + y^2) + 2 |b| y)) */ /* imag: |a^2-b^2| y + |b| ((x^2 + y^2) + 2 |a| x)) */ /* am, bm = upper bounds for a, b */ arf_get_mag(am, a); arf_get_mag(bm, b); /* v = x^2 + y^2 */ mag_mul(v, x, x); mag_addmul(v, y, y); /* u = |a| ((x^2 + y^2) + 2 |b| y) */ mag_mul_2exp_si(u, bm, 1); mag_mul(u, u, y); mag_add(u, u, v); mag_mul(u, u, am); /* v = |b| ((x^2 + y^2) + 2 |a| x) */ mag_mul_2exp_si(w, am, 1); mag_addmul(v, w, x); mag_mul(v, v, bm); /* w = |b^2 - a^2| (upper bound) */ if (arf_cmpabs(a, b) >= 0) mag_mul(w, am, am); else mag_mul(w, bm, bm); mag_addmul(u, w, x); mag_addmul(v, w, y); mag_div(arb_radref(acb_realref(res)), u, t); mag_div(arb_radref(acb_imagref(res)), v, t); _arb_arf_div_rounded_den_add_err(acb_realref(res), a, a2b2, inexact, prec); _arb_arf_div_rounded_den_add_err(acb_imagref(res), b, a2b2, inexact, prec); arf_neg(arb_midref(acb_imagref(res)), arb_midref(acb_imagref(res))); mag_clear(t); mag_clear(u); mag_clear(v); mag_clear(w); arf_clear(a2b2); } mag_clear(am); mag_clear(bm); #undef a #undef b #undef x #undef y }
void arb_mat_inv_cho_precomp(arb_mat_t X, const arb_mat_t L, slong prec) { slong n; if (arb_mat_nrows(X) != arb_mat_nrows(L) || arb_mat_ncols(X) != arb_mat_ncols(L)) { flint_printf("arb_mat_inv_cho_precomp: incompatible dimensions\n"); abort(); } if (arb_mat_is_empty(L)) return; n = arb_mat_nrows(L); if (n == 1) { arb_inv(arb_mat_entry(X, 0, 0), arb_mat_entry(L, 0, 0), prec); _arb_sqr(arb_mat_entry(X, 0, 0), arb_mat_entry(X, 0, 0), prec); return; } if (X == L) { flint_printf("arb_mat_inv_cho_precomp: unsupported aliasing\n"); abort(); } /* invert a 2x2 or larger matrix given its L * L^T decomposition */ { slong i, j, k; arb_struct *s; arb_mat_zero(X); s = _arb_vec_init(n); for (i = 0; i < n; i++) { arb_inv(s + i, arb_mat_entry(L, i, i), prec); } for (j = n-1; j >= 0; j--) { for (i = j; i >= 0; i--) { if (i == j) { arb_set(arb_mat_entry(X, i, j), s + i); } else { arb_zero(arb_mat_entry(X, i, j)); } for (k = i + 1; k < n; k++) { arb_submul(arb_mat_entry(X, i, j), arb_mat_entry(L, k, i), arb_mat_entry(X, k, j), prec); } arb_div(arb_mat_entry(X, i, j), arb_mat_entry(X, i, j), arb_mat_entry(L, i, i), prec); arb_set(arb_mat_entry(X, j, i), arb_mat_entry(X, i, j)); } } _arb_vec_clear(s, n); } }
void bernoulli_rev_init(bernoulli_rev_t iter, ulong nmax) { long j; fmpz_t t; arb_t x; arf_t u; int round1, round2; long wp; nmax -= (nmax % 2); iter->n = nmax; iter->alloc = 0; if (nmax < BERNOULLI_REV_MIN) return; iter->prec = wp = bernoulli_global_prec(nmax); iter->max_power = bernoulli_zeta_terms(nmax, iter->prec); iter->alloc = iter->max_power + 1; iter->powers = _fmpz_vec_init(iter->alloc); fmpz_init(iter->pow_error); arb_init(iter->prefactor); arb_init(iter->two_pi_squared); arb_init(x); fmpz_init(t); arf_init(u); /* precompute powers */ for (j = 3; j <= iter->max_power; j += 2) { arb_ui_pow_ui(x, j, nmax, bernoulli_power_prec(j, nmax, wp)); arb_inv(x, x, bernoulli_power_prec(j, nmax, wp)); round1 = arf_get_fmpz_fixed_si(t, arb_midref(x), -wp); fmpz_set(iter->powers + j, t); /* error: the radius, plus two roundings */ arf_set_mag(u, arb_radref(x)); round2 = arf_get_fmpz_fixed_si(t, u, -wp); fmpz_add_ui(t, t, (round1 != 0) + (round2 != 0)); if (fmpz_cmp(iter->pow_error, t) < 0) fmpz_set(iter->pow_error, t); } /* precompute (2pi)^2 and 2*(n!)/(2pi)^n */ arb_fac_ui(iter->prefactor, nmax, wp); arb_mul_2exp_si(iter->prefactor, iter->prefactor, 1); arb_const_pi(x, wp); arb_mul_2exp_si(x, x, 1); arb_mul(iter->two_pi_squared, x, x, wp); arb_pow_ui(x, iter->two_pi_squared, nmax / 2, wp); arb_div(iter->prefactor, iter->prefactor, x, wp); fmpz_clear(t); arb_clear(x); arf_clear(u); }