2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2014-06-04 16:12:22 +02:00
|
|
|
Copyright (C) 2013 Fredrik Johansson
|
|
|
|
|
2016-04-26 17:20:05 +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 Lesser General Public License (LGPL) as published
|
|
|
|
by the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2014-06-04 16:12:22 +02:00
|
|
|
|
|
|
|
#include "acb.h"
|
|
|
|
|
2021-09-19 15:07:07 +02:00
|
|
|
void acb_hypgeom_gamma_stirling_choose_param(int * reflect, slong * r, slong * n,
|
2015-11-05 17:43:36 +00:00
|
|
|
const acb_t x, int use_reflect, int digamma, slong prec);
|
2014-06-04 16:12:22 +02:00
|
|
|
|
2015-11-05 17:43:36 +00:00
|
|
|
void acb_gamma_stirling_eval(acb_t s, const acb_t z, slong nterms, int digamma, slong prec);
|
2014-06-04 16:12:22 +02:00
|
|
|
|
|
|
|
void
|
2015-11-05 17:43:36 +00:00
|
|
|
acb_digamma(acb_t y, const acb_t x, slong prec)
|
2014-06-04 16:12:22 +02:00
|
|
|
{
|
|
|
|
int reflect;
|
2015-11-05 17:43:36 +00:00
|
|
|
slong r, n, wp;
|
2014-06-04 16:12:22 +02:00
|
|
|
acb_t t, u, v;
|
|
|
|
|
2014-11-09 17:19:54 +01:00
|
|
|
if (acb_is_real(x))
|
|
|
|
{
|
|
|
|
arb_digamma(acb_realref(y), acb_realref(x), prec);
|
|
|
|
arb_zero(acb_imagref(y));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-04 16:12:22 +02:00
|
|
|
wp = prec + FLINT_BIT_COUNT(prec);
|
|
|
|
|
2021-09-19 15:07:07 +02:00
|
|
|
acb_hypgeom_gamma_stirling_choose_param(&reflect, &r, &n, x, 1, 1, wp);
|
2014-06-04 16:12:22 +02:00
|
|
|
|
|
|
|
acb_init(t);
|
|
|
|
acb_init(u);
|
|
|
|
acb_init(v);
|
|
|
|
|
|
|
|
/* psi(x) = psi((1-x)+r) - h(1-x,r) - pi*cot(pi*x) */
|
|
|
|
if (reflect)
|
|
|
|
{
|
|
|
|
acb_sub_ui(t, x, 1, wp);
|
|
|
|
acb_neg(t, t);
|
|
|
|
acb_cot_pi(v, x, wp);
|
|
|
|
arb_const_pi(acb_realref(u), wp);
|
|
|
|
acb_mul_arb(v, v, acb_realref(u), wp);
|
|
|
|
acb_rising2_ui(y, u, t, r, wp);
|
|
|
|
acb_div(u, u, y, wp);
|
|
|
|
acb_add(v, v, u, wp);
|
|
|
|
acb_add_ui(t, t, r, wp);
|
|
|
|
acb_gamma_stirling_eval(u, t, n, 1, wp);
|
|
|
|
acb_sub(y, u, v, wp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
acb_add_ui(t, x, r, wp);
|
|
|
|
acb_gamma_stirling_eval(u, t, n, 1, wp);
|
|
|
|
acb_rising2_ui(y, t, x, r, wp);
|
|
|
|
acb_div(t, t, y, wp);
|
|
|
|
acb_sub(y, u, t, prec);
|
|
|
|
}
|
|
|
|
|
|
|
|
acb_clear(t);
|
|
|
|
acb_clear(u);
|
|
|
|
acb_clear(v);
|
|
|
|
}
|
|
|
|
|