Пример #1
0
void
gamma_taylor_bound_remainder(fmpr_t err, const fmpr_t z, long n)
{
    fmpr_t t, u;

    gamma_taylor_bound_extend_cache(n + 1);

    fmpr_init(t);
    fmpr_init(u);

    /* denominator: 1 - r(n+1) * z, rounded down */
    fmpr_mul(t, gamma_taylor_bound_ratio_cache + n + 1,
        z, FMPRB_RAD_PREC, FMPR_RND_UP);
    fmpr_one(u);
    fmpr_sub(u, u, t, FMPRB_RAD_PREC, FMPR_RND_DOWN);

    if (fmpr_sgn(u) <= 0)
    {
        fmpr_pos_inf(err);
    }
    else
    {
        fmpr_pow_sloppy_ui(t, z, n, FMPRB_RAD_PREC, FMPR_RND_UP);
        fmpr_mul_2exp_si(t, t, gamma_taylor_bound_mag_cache[n + 1]);
        fmpr_div(err, t, u, FMPRB_RAD_PREC, FMPR_RND_UP);
    }

    fmpr_clear(t);
    fmpr_clear(u);
}
Пример #2
0
/* The error for eta(s) is bounded by 3/(3+sqrt(8))^n */
void
borwein_error(fmpr_t err, long n)
{
    fmpr_sqrt_ui(err, 8, FMPRB_RAD_PREC, FMPR_RND_DOWN);
    fmpr_add_ui(err, err, 3, FMPRB_RAD_PREC, FMPR_RND_DOWN);
    fmpr_pow_sloppy_ui(err, err, n, FMPRB_RAD_PREC, FMPR_RND_DOWN);
    fmpr_ui_div(err, 3, err, FMPRB_RAD_PREC, FMPR_RND_UP);
}
Пример #3
0
int main()
{
    slong iter;
    flint_rand_t state;

    flint_printf("binpow_uiui....");
    fflush(stdout);

    flint_randinit(state);

    for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
    {
        fmpr_t x, y;
        mag_t b;
        ulong m, n;

        fmpr_init(x);
        fmpr_init(y);
        mag_init(b);

        m = n_randtest(state);
        n = n_randtest(state);

        fmpr_one(x);
        fmpr_div_ui(x, x, m, 128, FMPR_RND_UP);
        fmpr_add_ui(x, x, 1, 128, FMPR_RND_UP);
        fmpr_pow_sloppy_ui(x, x, n, 128, FMPR_RND_UP);

        mag_binpow_uiui(b, m, n);
        mag_get_fmpr(y, b);

        MAG_CHECK_BITS(b)

        if (!(fmpr_cmpabs(x, y) <= 0))
        {
            flint_printf("FAIL\n\n");
            flint_printf("m = %wu\n\n", m);
            flint_printf("n = %wu\n\n", n);
            flint_printf("x = "); fmpr_printd(x, 10); flint_printf("\n\n");
            flint_printf("y = "); fmpr_printd(y, 10); flint_printf("\n\n");
            flint_abort();
        }

        fmpr_clear(x);
        fmpr_clear(y);
        mag_clear(b);
    }

    flint_randclear(state);
    flint_cleanup();
    flint_printf("PASS\n");
    return EXIT_SUCCESS;
}