Exemple #1
0
void
arb_zeta_ui_borwein_bsplit(arb_t x, ulong s, slong prec)
{
    zeta_bsplit_t sum;
    mag_t err;
    slong wp, n;

    /* zeta(0) = -1/2 */
    if (s == 0)
    {
        arb_set_si(x, -1);
        arb_mul_2exp_si(x, x, -1);
        return;
    }

    if (s == 1)
    {
        flint_printf("zeta_ui_borwein_bsplit: zeta(1)");
        abort();
    }

    n = prec / ERROR_B + 2;
    wp = prec + 30;

    zeta_bsplit_init(sum);
    zeta_bsplit(sum, 0, n + 1, n, s, 0, wp);

    /*  A/Q3 - B/Q3 / (C/Q1) = (A*C - B*Q1) / (Q3*C)    */
    arb_mul(sum->A, sum->A, sum->C, wp);
    arb_mul(sum->B, sum->B, sum->Q1, wp);
    arb_sub(sum->A, sum->A, sum->B, wp);
    arb_mul(sum->Q3, sum->Q3, sum->C, wp);
    arb_div(sum->C, sum->A, sum->Q3, wp);

    mag_init(err);
    mag_borwein_error(err, n);
    mag_add(arb_radref(sum->C), arb_radref(sum->C), err);
    mag_clear(err);

    /* convert from eta(s) to zeta(s) */
    arb_div_2expm1_ui(x, sum->C, s - 1, wp);
    arb_mul_2exp_si(x, x, s - 1);

    zeta_bsplit_clear(sum);
}
Exemple #2
0
void
zeta_ui_borwein_bsplit(fmprb_t x, ulong s, long prec)
{
    zeta_bsplit_t sum;
    fmpr_t err;
    long wp, n;

    /* zeta(0) = -1/2 */
    if (s == 0)
    {
        fmpr_set_si_2exp_si(fmprb_midref(x), -1, -1);
        fmpr_zero(fmprb_radref(x));
        return;
    }

    if (s == 1)
    {
        printf("zeta_ui_borwein_bsplit: zeta(1)");
        abort();
    }

    n = prec / ERROR_B + 2;
    wp = prec + 30;

    zeta_bsplit_init(sum);
    zeta_bsplit(sum, 0, n + 1, n, s, 0, wp);

    /*  A/Q3 - B/Q3 / (C/Q1) = (A*C - B*Q1) / (Q3*C)    */
    fmprb_mul(sum->A, sum->A, sum->C, wp);
    fmprb_mul(sum->B, sum->B, sum->Q1, wp);
    fmprb_sub(sum->A, sum->A, sum->B, wp);
    fmprb_mul(sum->Q3, sum->Q3, sum->C, wp);
    fmprb_div(sum->C, sum->A, sum->Q3, wp);

    fmpr_init(err);
    borwein_error(err, n);
    fmprb_add_error_fmpr(sum->C, err);
    fmpr_clear(err);

    /* convert from eta(s) to zeta(s) */
    fmprb_div_2expm1_ui(x, sum->C, s - 1, wp);
    fmprb_mul_2exp_si(x, x, s - 1);

    zeta_bsplit_clear(sum);
}
Exemple #3
0
static void
zeta_bsplit(zeta_bsplit_t L, slong a, slong b,
    slong n, slong s, int cont, slong bits)
{
    if (a + 1 == b)
    {
        zeta_coeff_k(L, a, n, s);
    }
    else
    {
        zeta_bsplit_t R;

        slong m = (a + b) / 2;

        zeta_bsplit(L, m, b, n, s, 1, bits);

        zeta_bsplit_init(R);
        zeta_bsplit(R, a, m, n, s, 1, bits);

        arb_mul(L->B, L->B, R->D, bits);
        arb_addmul(L->B, L->A, R->C, bits);

        arb_mul(L->B, L->B, R->Q2, bits);
        arb_addmul(L->B, R->B, L->Q3, bits);

        arb_mul(L->A, L->A, R->Q3, bits);
        arb_addmul(L->A, R->A, L->Q3, bits);

        arb_mul(L->C, L->C, R->D, bits);
        arb_addmul(L->C, R->C, L->Q1, bits);

        if (cont)
        {
            arb_mul(L->D, L->D, R->D, bits);
            arb_mul(L->Q2, L->Q2, R->Q2, bits);
        }

        arb_mul(L->Q1, L->Q1, R->Q1, bits);
        arb_mul(L->Q3, L->Q3, R->Q3, bits);

        zeta_bsplit_clear(R);
    }
}