Skip to main content

thermite_special/tables/
cot_pi.rs

1// @generated by cot_pi.py, alongside. DO NOT EDIT BY HAND.
2//! Coefficient rows for the n-th derivative of `$\cot(\pi x)$`, the polygamma
3//! reflection kernel.
4//!
5//! Row `n - 1` holds the nonzero coefficients of the cosine polynomial in
6//!
7//! ```math
8//! \frac{\mathrm{d}^n}{\mathrm{d}x^n}\cot(\pi x)
9//!     = \pi^n\,\frac{P_n(\cos\pi x)}{\sin^{n+1}(\pi x)}
10//! ```
11//!
12//! ascending in `$\cos^2$`. `$P_n$` is even for odd `n` and `$\cos\pi x$` times an
13//! even polynomial for even `n` (the caller multiplies that single factor back).
14//! Cosine powers rather than multiple angles keep every term zero at half-integer
15//! arguments, right where the derivative has its minimum, so there is no
16//! cancellation there (Boost.Math `poly_cot_pi`).
17//!
18//! The exact integer coefficients outgrow every float format (row 20 tops out near
19//! `$5\times10^{18}$`). Each entry here is the format's nearest value, one rounding.
20//! Rows stop at `n = 20`, Boost's tabulated range. Past it the reflection is not
21//! implemented (see `polygamma_impl`).
22
23use thermite::element::FloatElement;
24
25/// Coefficient rows for the derivatives of `$\cot(\pi x)$`. See the [module docs](self).
26pub trait CotPiDerivatives: FloatElement {
27    /// Row `n - 1` is the polynomial for the n-th derivative.
28    const COT_PI_ROWS: &'static [&'static [Self]];
29}
30
31impl CotPiDerivatives for f32 {
32    #[rustfmt::skip]
33    const COT_PI_ROWS: &'static [&'static [f32]] = &[
34        &[-1.0],  // n = 1
35        &[2.0],  // n = 2
36        &[-2.0, -4.0],  // n = 3
37        &[16.0, 8.0],  // n = 4
38        &[-16.0, -88.0, -16.0],  // n = 5
39        &[272.0, 416.0, 32.0],  // n = 6
40        &[-272.0, -2.88e+03, -1824.0, -64.0],  // n = 7
41        &[7936.0, 24576.0, 7.68e+03, 128.0],  // n = 8
42        &[-7936.0, -137216.0, -185856.0, -31616.0, -256.0],  // n = 9
43        &[353792.0, 1841152.0, 1304832.0, 128512.0, 512.0],  // n = 10
44        &[-353792.0, -9061376.0, -21253376.0, -8728576.0, -518656.0, -1024.0],  // n = 11
45        &[22368256.0, 1.7562726e+08, 2.2239846e+08, 56520704.0, 2084864.0, 2048.0],  // n = 12
46        &[-22368256.0, -7.9530086e+08, -2.868265e+09, -2.1748326e+09, -3.57888e+08, -8361984.0, -4096.0],  // n = 13
47        &[1.9037573e+09, 2.101667e+10, 4.1731645e+10, 2.0261765e+10, 2.2309478e+09, 33497088.0, 8192.0],  // n = 14
48        &[-1.9037573e+09, -8.970261e+10, -4.6085826e+11, -5.591488e+11, -1.8217265e+11, -1.3754155e+10, -1.3409485e+08, -16384.0],  // n = 15
49        &[2.0986534e+11, 3.0992698e+12, 8.885193e+12, 7.048869e+12, 1.5949228e+12, 8.413407e+10, 5.3660877e+08, 32768.0],  // n = 16
50        &[-2.0986534e+11, -1.2655655e+13, -8.781573e+13, -1.5596439e+14, -8.4843e+13, -1.3684856e+13, -5.1178032e+11, -2.1469266e+09, -65536.0],  // n = 17
51        &[2.9088884e+13, 5.5375342e+14, 2.1652067e+15, 2.5503167e+15, 9.852785e+14, 1.1562022e+14, 3.1007388e+12, 8.588755e+09, 131072.0],  // n = 18
52        &[-2.9088884e+13, -2.1848602e+15, -1.9686088e+16, -4.8165108e+16, -3.9471308e+16, -1.1124607e+16, -9.6527135e+14, -1.8733265e+13, -3.4357248e+10, -262144.0],  // n = 19
53        &[4.951498e+15, 1.1807184e+17, 6.0396806e+17, 9.90082e+17, 5.849018e+17, 1.2282934e+17, 7.9844365e+15, 1.129493e+14, 1.3743371e+11, 524288.0],  // n = 20
54    ];
55}
56
57impl CotPiDerivatives for f64 {
58    #[rustfmt::skip]
59    const COT_PI_ROWS: &'static [&'static [f64]] = &[
60        &[-1.0],  // n = 1
61        &[2.0],  // n = 2
62        &[-2.0, -4.0],  // n = 3
63        &[16.0, 8.0],  // n = 4
64        &[-16.0, -88.0, -16.0],  // n = 5
65        &[272.0, 416.0, 32.0],  // n = 6
66        &[-272.0, -2880.0, -1824.0, -64.0],  // n = 7
67        &[7936.0, 24576.0, 7680.0, 128.0],  // n = 8
68        &[-7936.0, -137216.0, -185856.0, -31616.0, -256.0],  // n = 9
69        &[353792.0, 1841152.0, 1304832.0, 128512.0, 512.0],  // n = 10
70        &[-353792.0, -9061376.0, -21253376.0, -8728576.0, -518656.0, -1024.0],  // n = 11
71        &[22368256.0, 175627264.0, 222398464.0, 56520704.0, 2084864.0, 2048.0],  // n = 12
72        &[-22368256.0, -795300864.0, -2868264960.0, -2174832640.0, -357888000.0, -8361984.0, -4096.0],  // n = 13
73        &[1903757312.0, 21016670208.0, 41731645440.0, 20261765120.0, 2230947840.0, 33497088.0, 8192.0],  // n = 14
74        &[-1903757312.0, -89702612992.0, -460858269696.0, -559148810240.0, -182172651520.0, -13754155008.0, -134094848.0, -16384.0],  // n = 15
75        &[209865342976.0, 3099269660672.0, 8885192097792.0, 7048869314560.0, 1594922762240.0, 84134068224.0, 536608768.0, 32768.0],  // n = 16
76        &[-209865342976.0, -12655654469632.0, -87815735738368.0, -155964390375424.0, -84842998005760.0, -13684856848384.0, -511780323328.0, -2146926592.0, -65536.0],  // n = 17
77        &[29088885112832.0, 553753414467584.0, 2165206642589696.0, 2550316668551168.0, 985278548541440.0, 115620218667008.0, 3100738912256.0, 8588754944.0, 131072.0],  // n = 18
78        &[-29088885112832.0, -2184860175433728.0, -1.9686087844429824e+16, -4.816510967611392e+16, -3.947130695948698e+16, -1.1124607890751488e+16, -965271355195392.0, -18733264797696.0, -34357248000.0, -262144.0],  // n = 19
79        &[4951498053124096.0, 1.180718345355264e+17, 6.039680635675607e+17, 9.900819911414907e+17, 5.849017624213586e+17, 1.2282933516985958e+17, 7984436548730880.0, 112949304754176.0, 137433710592.0, 524288.0],  // n = 20
80    ];
81}
Last built: 2026-09-08 21:35:55 UTC