2012-09-03 16:32:26 +02:00
|
|
|
/*=============================================================================
|
|
|
|
|
|
|
|
This file is part of ARB.
|
|
|
|
|
|
|
|
ARB is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ARB is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with ARB; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
=============================================================================*/
|
|
|
|
/******************************************************************************
|
|
|
|
|
|
|
|
Copyright (C) 2012 Fredrik Johansson
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-02-28 17:24:50 +01:00
|
|
|
#include "zeta.h"
|
2013-03-15 16:16:09 +01:00
|
|
|
#include "bernoulli.h"
|
2012-09-03 16:32:26 +02:00
|
|
|
|
|
|
|
void
|
2013-03-27 15:54:05 +01:00
|
|
|
zeta_ui_bernoulli(fmprb_t x, ulong n, long prec)
|
2012-09-03 16:32:26 +02:00
|
|
|
{
|
|
|
|
fmpq_t b;
|
|
|
|
fmprb_t t, f;
|
|
|
|
long wp;
|
|
|
|
|
|
|
|
if (n % 2)
|
|
|
|
abort();
|
|
|
|
|
|
|
|
wp = prec + FLINT_BIT_COUNT(n) + 2;
|
|
|
|
|
|
|
|
fmpq_init(b);
|
|
|
|
fmprb_init(t);
|
|
|
|
fmprb_init(f);
|
|
|
|
|
2013-03-15 16:16:09 +01:00
|
|
|
bernoulli_fmpq_ui(b, n);
|
2012-09-03 16:32:26 +02:00
|
|
|
fmprb_set_fmpq(x, b, wp);
|
|
|
|
|
|
|
|
fmprb_const_pi(t, wp);
|
|
|
|
fmprb_mul_2exp_si(t, t, 1);
|
|
|
|
fmprb_pow_ui(t, t, n, wp);
|
|
|
|
|
|
|
|
fmprb_fac_ui(f, n, wp);
|
|
|
|
|
|
|
|
fmprb_div(t, t, f, wp);
|
|
|
|
fmprb_mul(x, x, t, wp);
|
|
|
|
fmprb_abs(x, x);
|
|
|
|
fmprb_mul_2exp_si(x, x, -1);
|
|
|
|
|
|
|
|
fmprb_clear(t);
|
|
|
|
fmprb_clear(f);
|
|
|
|
fmpq_clear(b);
|
|
|
|
}
|
2013-03-27 15:54:05 +01:00
|
|
|
|