1 /*
2 Copyright (C) 2014 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 "acb.h"
13
14 void
acb_chebyshev_u_ui(acb_t y,ulong n,const acb_t x,slong prec)15 acb_chebyshev_u_ui(acb_t y, ulong n, const acb_t x, slong prec)
16 {
17 acb_t a, b;
18
19 if (n <= 1)
20 {
21 if (n == 0)
22 {
23 acb_one(y);
24 }
25 else
26 {
27 acb_set_round(y, x, prec);
28 acb_mul_2exp_si(y, y, 1);
29 }
30 return;
31 }
32
33 acb_init(a);
34 acb_init(b);
35
36 acb_chebyshev_u2_ui(a, b, n / 2, x, prec);
37
38 if (n % 2 == 0)
39 {
40 acb_add(y, a, b, prec);
41 acb_sub(b, a, b, prec);
42 acb_mul(y, y, b, prec);
43 }
44 else
45 {
46 acb_submul(b, a, x, prec);
47 acb_mul(y, a, b, prec);
48 acb_mul_2exp_si(y, y, 1);
49 acb_neg(y, y);
50 }
51
52 acb_clear(a);
53 acb_clear(b);
54 }
55
56