File: k_jet.c

package info (click to toggle)
flint-arb 1%3A2.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,672 kB
  • sloc: ansic: 204,753; sh: 570; makefile: 287; python: 268
file content (93 lines) | stat: -rw-r--r-- 2,098 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
    Copyright (C) 2014 Fredrik Johansson

    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/>.
*/

#include "acb_elliptic.h"

void
acb_elliptic_k_jet(acb_ptr w, const acb_t m, slong len, slong prec)
{
    acb_t t, u, msub1m, m2sub1;
    slong k, n;

    if (len < 1)
        return;

    if (len == 1)
    {
        acb_elliptic_k(w, m, prec);
        return;
    }

    if (acb_is_zero(m))
    {
        acb_const_pi(w, prec);
        acb_mul_2exp_si(w, w, -1);

        for (k = 1; k < len; k++)
        {
            acb_mul_ui(w + k, w + k - 1, (2 * k - 1) * (2 * k - 1), prec);
            acb_div_ui(w + k, w + k, 4 * k * k, prec);
        }

        return;
    }

    acb_init(t);
    acb_init(u);
    acb_init(msub1m);
    acb_init(m2sub1);

    acb_sub_ui(msub1m, m, 1, prec);
    acb_neg(t, msub1m);
    acb_sqrt(t, t, prec);
    acb_mul(msub1m, msub1m, m, prec);

    acb_mul_2exp_si(m2sub1, m, 1);
    acb_sub_ui(m2sub1, m2sub1, 1, prec);

    acb_agm1_cpx(w, t, 2, prec);

    /* pi M'(t) / (4 t M(t)^2) */
    acb_mul(u, w, w, prec);
    acb_mul(t, t, u, prec);
    acb_div(w + 1, w + 1, t, prec);

    acb_const_pi(u, prec);
    acb_mul(w + 1, w + 1, u, prec);
    acb_mul_2exp_si(w + 1, w + 1, -2);

    /* pi / (2 M(t)) */
    acb_const_pi(u, prec);
    acb_div(w, u, w, prec);
    acb_mul_2exp_si(w, w, -1);

    acb_inv(t, msub1m, prec);

    for (k = 2; k < len; k++)
    {
        n = k - 2;

        acb_mul_ui(w + k, w + n, (2 * n + 1) * (2 * n + 1), prec);

        acb_mul(u, w + n + 1, m2sub1, prec);
        acb_addmul_ui(w + k, u, (n + 1) * (n + 1) * 4, prec);

        acb_mul(w + k, w + k, t, prec);
        acb_div_ui(w + k, w + k, 4 * (n + 1) * (n + 2), prec);
        acb_neg(w + k, w + k);
    }

    acb_clear(t);
    acb_clear(u);
    acb_clear(msub1m);
    acb_clear(m2sub1);
}