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
//! Bespoke narrow-`GUARD` `atan_strict` kernel slot for `D57<SCALE>`
//! with `SCALE ∈ 18..=22`.
//!
//! Companion to [`super::lookup_d57_s18_22_sincos`] and
//! [`crate::algos::ln::lookup_d57_s18_22`] /
//! [`crate::algos::exp::lookup_d57_s18_22`]: the shared wide-tier
//! `atan_fixed` core uses `GUARD = 30`. At `SCALE ∈ 18..=22` the
//! atan Taylor / Euler-acceleration series converges in ~20-30
//! rounded muls (vs ~100+ at SCALE 57), so a narrower
//! `GUARD_NARROW = 14` leaves storage 14 decimal digits below `w`,
//! many orders of magnitude below half a storage ULP.
//!
//! Per-call working width drops from `SCALE + 30 = 48..52` to
//! `SCALE + 14 = 32..36` — roughly two-thirds of the bits.
//!
//! ## `GUARD_NARROW` selection
//!
//! `atan_fixed` may invoke a half-angle pre-reduction for `|x| > 1`
//! plus a Taylor (or Euler-accelerated) series. At `w = 32..36` and
//! reduced argument the series converges in ~30 iterations. Each
//! rounded mul contributes ≤ 0.5 LSB-of-w of uncorrelated drift;
//! pre-reduction adds a few more LSB. Total accumulated error is
//! ~20 LSB-of-w.
//!
//! With `GUARD_NARROW = 14`, storage scale is `w - 14`, so 20 LSB-of-w
//! is `20·10⁻¹⁴` in storage units — 13 orders of magnitude below half
//! a storage ULP.
use cratewide_trig_d57 as core;
use crateRoundingMode;
use crateInt192;
/// Narrow guard for the SCALE 18..=22 atan slot. Slightly larger than
/// the sincos/ln/exp `GUARD_NARROW = 12` because atan's series can
/// require slightly more iterations after argument reduction.
const GUARD_NARROW: u32 = 10;
/// `atan_strict` for `D57<SCALE>` with `SCALE ∈ 18..=22`.
///
/// Routes the canonical [`core::atan_fixed`] kernel through a narrower
/// working width `w = SCALE + GUARD_NARROW`.
pub