void acb_hypgeom_bessel_jy(acb_t res1, acb_t res2, const acb_t nu, const acb_t z, slong prec) { acb_t jnu, t, u, v; acb_init(jnu); acb_init(t); acb_init(u); acb_init(v); acb_hypgeom_bessel_j(jnu, nu, z, prec); if (acb_is_int(nu)) { int is_real = acb_is_real(nu) && acb_is_real(z) && arb_is_positive(acb_realref(z)); acb_mul_onei(t, z); acb_hypgeom_bessel_k(t, nu, t, prec); acb_onei(u); acb_pow(u, u, nu, prec); acb_mul(t, t, u, prec); acb_const_pi(u, prec); acb_div(t, t, u, prec); acb_mul_2exp_si(t, t, 1); acb_neg(t, t); phase(v, acb_realref(z), acb_imagref(z)); acb_mul(u, jnu, v, prec); acb_mul_onei(u, u); acb_sub(res2, t, u, prec); if (is_real) arb_zero(acb_imagref(res2)); } else { acb_sin_cos_pi(t, u, nu, prec); acb_mul(v, jnu, u, prec); acb_neg(u, nu); acb_hypgeom_bessel_j(u, u, z, prec); acb_sub(v, v, u, prec); acb_div(res2, v, t, prec); } if (res1 != NULL) acb_set(res1, jnu); acb_clear(jnu); acb_clear(t); acb_clear(u); acb_clear(v); }
void acb_unit_root(acb_t res, ulong order, slong prec) { switch (order) { case 1: acb_one(res); break; case 2: acb_set_si(res, -1); break; case 4: acb_onei(res); break; default: _acb_unit_root(res, order, prec); break; } }
int f_elliptic_p_laurent_n(acb_ptr res, const acb_t z, void * param, slong order, slong prec) { slong n; acb_t tau; if (order > 1) flint_abort(); /* Would be needed for Taylor method. */ n = ((slong *)(param))[0]; acb_init(tau); acb_onei(tau); acb_modular_elliptic_p(res, z, tau, prec); acb_pow_si(tau, z, -n - 1, prec); acb_mul(res, res, tau, prec); acb_clear(tau); return 0; }
int main() { long iter; flint_rand_t state; printf("eta...."); fflush(stdout); flint_randinit(state); /* Test functional equation */ for (iter = 0; iter < 10000; iter++) { acb_t tau1, tau2, z1, z2, z3, t; fmpq_t arg; long e0, prec0, prec1, prec2; psl2z_t g; psl2z_init(g); fmpq_init(arg); acb_init(tau1); acb_init(tau2); acb_init(z1); acb_init(z2); acb_init(z3); acb_init(t); e0 = 1 + n_randint(state, 200); prec0 = 2 + n_randint(state, 2000); prec1 = 2 + n_randint(state, 2000); prec2 = 2 + n_randint(state, 2000); acb_randtest(tau1, state, prec0, e0); acb_randtest(tau2, state, prec0, e0); acb_randtest(z1, state, prec0, e0); acb_randtest(z2, state, prec0, e0); psl2z_randtest(g, state, 1 + n_randint(state, 200)); acb_modular_transform(tau2, g, tau1, prec0); acb_modular_eta(z1, tau1, prec1); acb_modular_eta(z2, tau2, prec2); /* apply transformation */ fmpq_set_si(arg, acb_modular_epsilon_arg(g), 12); arb_sin_cos_pi_fmpq(acb_imagref(t), acb_realref(t), arg, prec1); acb_mul(z3, z1, t, prec1); acb_mul_fmpz(t, tau1, &g->c, prec1); acb_add_fmpz(t, t, &g->d, prec1); acb_sqrt(t, t, prec1); acb_mul(z3, z3, t, prec1); if (!acb_overlaps(z3, z2)) { printf("FAIL (overlap)\n"); printf("tau1 = "); acb_printd(tau1, 15); printf("\n\n"); printf("tau2 = "); acb_printd(tau2, 15); printf("\n\n"); printf("g = "); psl2z_print(g); printf("\n\n"); printf("z1 = "); acb_printd(z1, 15); printf("\n\n"); printf("z2 = "); acb_printd(z2, 15); printf("\n\n"); printf("z3 = "); acb_printd(z3, 15); printf("\n\n"); abort(); } acb_modular_eta(tau1, tau1, prec2); if (!acb_overlaps(z1, tau1)) { printf("FAIL (aliasing)\n"); printf("tau1 = "); acb_print(tau1); printf("\n\n"); printf("tau2 = "); acb_print(tau2); printf("\n\n"); printf("z1 = "); acb_print(z1); printf("\n\n"); printf("z2 = "); acb_print(z2); printf("\n\n"); abort(); } acb_clear(tau1); acb_clear(tau2); acb_clear(z1); acb_clear(z2); acb_clear(z3); acb_clear(t); psl2z_clear(g); fmpq_clear(arg); } /* Test special values */ for (iter = 0; iter < 100; iter++) { acb_t tau, z; arb_t t, u; long prec; acb_init(tau); acb_init(z); arb_init(t); arb_init(u); prec = 2 + n_randint(state, 2000); acb_randtest(z, state, prec, 10); acb_onei(tau); acb_modular_eta(z, tau, prec); arb_one(t); arb_mul_2exp_si(t, t, -2); arb_gamma(t, t, prec); arb_const_pi(u, prec); arb_root(u, u, 4, prec); arb_pow_ui(u, u, 3, prec); arb_div(t, t, u, prec); arb_mul_2exp_si(t, t, -1); if (!arb_overlaps(acb_realref(z), t) || !arb_contains_zero(acb_imagref(z))) { printf("FAIL (value 1)\n"); printf("tau = "); acb_print(tau); printf("\n\n"); printf("z = "); acb_print(z); printf("\n\n"); abort(); } acb_clear(tau); acb_clear(z); arb_clear(t); arb_clear(u); } flint_randclear(state); flint_cleanup(); printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("erfi_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 200 * arb_test_multiplier(); iter++) { slong m, n1, n2, bits1, bits2, bits3; acb_poly_t S, A, B, C; acb_t I; bits1 = 2 + n_randint(state, 200); bits2 = 2 + n_randint(state, 200); bits3 = 2 + n_randint(state, 200); m = 1 + n_randint(state, 10); n1 = 1 + n_randint(state, 10); n2 = 1 + n_randint(state, 10); acb_poly_init(S); acb_poly_init(A); acb_poly_init(B); acb_poly_init(C); acb_init(I); acb_poly_randtest(S, state, m, bits1, 3); acb_poly_randtest(A, state, m, bits1, 3); acb_poly_randtest(B, state, m, bits1, 3); acb_hypgeom_erfi_series(A, S, n1, bits2); acb_onei(I); acb_poly_set_acb(C, I); acb_poly_mul(B, S, C, bits3); acb_hypgeom_erf_series(B, B, n2, bits3); acb_poly_neg(C, C); acb_poly_mul(B, B, C, bits3); acb_poly_set(C, A); acb_poly_truncate(C, FLINT_MIN(n1, n2)); acb_poly_truncate(B, FLINT_MIN(n1, n2)); if (!acb_poly_overlaps(B, C)) { flint_printf("FAIL\n\n"); flint_printf("S = "); acb_poly_printd(S, 15); flint_printf("\n\n"); flint_printf("A = "); acb_poly_printd(A, 15); flint_printf("\n\n"); flint_printf("B = "); acb_poly_printd(B, 15); flint_printf("\n\n"); abort(); } acb_hypgeom_erfi_series(S, S, n1, bits2); if (!acb_poly_overlaps(A, S)) { flint_printf("FAIL (aliasing)\n\n"); abort(); } acb_poly_clear(S); acb_poly_clear(A); acb_poly_clear(B); acb_poly_clear(C); acb_clear(I); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("fresnel...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++) { acb_t z, z2, s, c, u, v; slong prec1, prec2; int normalized; prec1 = 2 + n_randint(state, 500); prec2 = 2 + n_randint(state, 500); acb_init(z); acb_init(z2); acb_init(s); acb_init(c); acb_init(u); acb_init(v); acb_randtest_special(z, state, 1 + n_randint(state, 500), 1 + n_randint(state, 100)); acb_randtest_special(s, state, 1 + n_randint(state, 500), 1 + n_randint(state, 100)); acb_randtest_special(c, state, 1 + n_randint(state, 500), 1 + n_randint(state, 100)); normalized = n_randint(state, 2); /* test S(z) + i C(z) = sqrt(pi/2) (1+i)/2 erf((1+i)/sqrt(2) z) */ /* u = rhs */ acb_onei(u); acb_sqrt(u, u, prec1); acb_mul(u, u, z, prec1); acb_hypgeom_erf(u, u, prec1); acb_mul_onei(v, u); acb_add(u, u, v, prec1); acb_mul_2exp_si(u, u, -1); acb_const_pi(v, prec1); acb_mul_2exp_si(v, v, -1); acb_sqrt(v, v, prec1); acb_mul(u, u, v, prec1); if (normalized) { acb_const_pi(v, prec2); acb_mul_2exp_si(v, v, -1); acb_sqrt(v, v, prec2); acb_div(z2, z, v, prec2); } else { acb_set(z2, z); } switch (n_randint(state, 4)) { case 0: acb_hypgeom_fresnel(s, c, z2, normalized, prec2); break; case 1: acb_hypgeom_fresnel(s, NULL, z2, normalized, prec2); acb_hypgeom_fresnel(NULL, c, z2, normalized, prec2); break; case 2: acb_set(s, z2); acb_hypgeom_fresnel(s, c, s, normalized, prec2); break; case 3: acb_set(c, z2); acb_hypgeom_fresnel(s, c, c, normalized, prec2); break; default: acb_hypgeom_fresnel(s, c, z2, normalized, prec2); } if (normalized) { acb_mul(s, s, v, prec2); acb_mul(c, c, v, prec2); } acb_mul_onei(v, c); acb_add(v, v, s, prec2); if (!acb_overlaps(u, v)) { flint_printf("FAIL: overlap\n\n"); flint_printf("z = "); acb_printd(z, 30); flint_printf("\n\n"); flint_printf("s = "); acb_printd(s, 30); flint_printf("\n\n"); flint_printf("c = "); acb_printd(c, 30); flint_printf("\n\n"); flint_printf("u = "); acb_printd(u, 30); flint_printf("\n\n"); flint_printf("v = "); acb_printd(v, 30); flint_printf("\n\n"); abort(); } acb_clear(z); acb_clear(z2); acb_clear(s); acb_clear(c); acb_clear(u); acb_clear(v); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { long iter; flint_rand_t state; printf("det...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000; iter++) { fmpq_mat_t Q; fmpq_t Qdet; acb_mat_t A; acb_t Adet, imagunit; long n, qbits, prec; int imaginary; n = n_randint(state, 8); qbits = 1 + n_randint(state, 100); prec = 2 + n_randint(state, 200); imaginary = n_randint(state, 2); fmpq_mat_init(Q, n, n); fmpq_init(Qdet); acb_mat_init(A, n, n); acb_init(Adet); acb_init(imagunit); fmpq_mat_randtest(Q, state, qbits); fmpq_mat_det(Qdet, Q); acb_mat_set_fmpq_mat(A, Q, prec); if (imaginary) { acb_onei(imagunit); acb_mat_scalar_mul_acb(A, A, imagunit, prec); } acb_mat_det(Adet, A, prec); if (imaginary) { acb_onei(imagunit); acb_inv(imagunit, imagunit, prec); acb_pow_ui(imagunit, imagunit, n, prec); acb_mul(Adet, Adet, imagunit, prec); } if (!acb_contains_fmpq(Adet, Qdet)) { printf("FAIL (containment, iter = %ld)\n", iter); printf("n = %ld, prec = %ld\n", n, prec); printf("\n"); printf("Q = \n"); fmpq_mat_print(Q); printf("\n\n"); printf("Qdet = \n"); fmpq_print(Qdet); printf("\n\n"); printf("A = \n"); acb_mat_printd(A, 15); printf("\n\n"); printf("Adet = \n"); acb_printd(Adet, 15); printf("\n\n"); printf("Adet = \n"); acb_print(Adet); printf("\n\n"); abort(); } fmpq_mat_clear(Q); fmpq_clear(Qdet); acb_mat_clear(A); acb_clear(Adet); acb_clear(imagunit); } flint_randclear(state); flint_cleanup(); printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("j...."); fflush(stdout); flint_randinit(state); /* Test SL2Z invariance */ for (iter = 0; iter < 10000; iter++) { acb_t tau1, tau2, z1, z2; slong e0, prec0, prec1, prec2; psl2z_t g; psl2z_init(g); acb_init(tau1); acb_init(tau2); acb_init(z1); acb_init(z2); e0 = 1 + n_randint(state, 100); prec0 = 2 + n_randint(state, 2000); prec1 = 2 + n_randint(state, 2000); prec2 = 2 + n_randint(state, 2000); acb_randtest(tau1, state, prec0, e0); acb_randtest(tau2, state, prec0, e0); acb_randtest(z1, state, prec0, e0); acb_randtest(z2, state, prec0, e0); psl2z_randtest(g, state, 1 + n_randint(state, 200)); acb_modular_transform(tau2, g, tau1, prec0); acb_modular_j(z1, tau1, prec1); acb_modular_j(z2, tau2, prec2); if (!acb_overlaps(z1, z2)) { flint_printf("FAIL (overlap)\n"); flint_printf("tau1 = "); acb_print(tau1); flint_printf("\n\n"); flint_printf("tau2 = "); acb_print(tau2); flint_printf("\n\n"); flint_printf("z1 = "); acb_print(z1); flint_printf("\n\n"); flint_printf("z2 = "); acb_print(z2); flint_printf("\n\n"); abort(); } acb_modular_j(tau1, tau1, prec2); if (!acb_overlaps(z1, tau1)) { flint_printf("FAIL (aliasing)\n"); flint_printf("tau1 = "); acb_print(tau1); flint_printf("\n\n"); flint_printf("tau2 = "); acb_print(tau2); flint_printf("\n\n"); flint_printf("z1 = "); acb_print(z1); flint_printf("\n\n"); flint_printf("z2 = "); acb_print(z2); flint_printf("\n\n"); abort(); } acb_clear(tau1); acb_clear(tau2); acb_clear(z1); acb_clear(z2); psl2z_clear(g); } /* Test special values */ for (iter = 0; iter < 100; iter++) { acb_t tau, z; slong prec; acb_init(tau); acb_init(z); prec = 2 + n_randint(state, 2000); acb_randtest(z, state, prec, 10); acb_onei(tau); acb_modular_j(z, tau, prec); acb_sub_ui(z, z, 1728, prec); if (!acb_contains_zero(z)) { flint_printf("FAIL (value 1)\n"); flint_printf("tau = "); acb_print(tau); flint_printf("\n\n"); flint_printf("z = "); acb_print(z); flint_printf("\n\n"); abort(); } acb_set_ui(tau, 2); acb_div_ui(tau, tau, 3, prec); acb_exp_pi_i(tau, tau, prec); acb_modular_j(z, tau, prec); if (!acb_contains_zero(z)) { flint_printf("FAIL (value 2)\n"); flint_printf("tau = "); acb_print(tau); flint_printf("\n\n"); flint_printf("z = "); acb_print(z); flint_printf("\n\n"); abort(); } acb_clear(tau); acb_clear(z); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }