1 /*
2 Copyright (C) 2017 Fredrik Johansson
3
4 This file is part of Arb.
5
6 Arb is free software: you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License (LGPL) as published
8 by the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version. See <http://www.gnu.org/licenses/>.
10 */
11
12 #include "arb.h"
13
14 void
arb_csch(arb_t res,const arb_t x,slong prec)15 arb_csch(arb_t res, const arb_t x, slong prec)
16 {
17 if (arb_contains_zero(x) || !arb_is_finite(x))
18 {
19 arb_indeterminate(res);
20 }
21 else if (arf_cmpabs_2exp_si(arb_midref(x), 0) > 0)
22 {
23 arb_t t;
24 arb_init(t);
25
26 if (arf_sgn(arb_midref(x)) > 0)
27 {
28 arb_neg(t, x);
29 arb_exp(t, t, prec + 4);
30 arb_mul(res, t, t, prec + 4);
31 arb_sub_ui(res, res, 1, prec + 4);
32 arb_div(res, t, res, prec);
33 arb_neg(res, res);
34 }
35 else
36 {
37 arb_exp(t, x, prec + 4);
38 arb_mul(res, t, t, prec + 4);
39 arb_sub_ui(res, res, 1, prec + 4);
40 arb_div(res, t, res, prec);
41 }
42
43 arb_mul_2exp_si(res, res, 1);
44 arb_clear(t);
45 }
46 else
47 {
48 arb_sinh(res, x, prec + 4);
49 arb_inv(res, res, prec);
50 }
51 }
52
53