Expand description
Nested second-order forward-AD dual for FD-free high-order cross-checks (#932).
Dual2<S> is a single-direction second-order jet (value, first and second
derivative in ONE direction) over a scalar field S. Because the field is
generic, it composes with itself: Dual2<Dual2<f64>> carries every mixed
partial ∂^i_a ∂^j_b for i, j ∈ {0, 1, 2}, i.e. the full 2 + 2 = 4th-order
bidirectional derivative in two INDEPENDENT directions a, b.
Why this exists: the flexible survival marginal-slope Jet4 tower (the
moving-boundary implicit-intercept path, gam#932) is the last derivative
surface whose fourth-order channel is verified only by a finite-difference
stencil — the hand reference is provably incomplete there, and a 4th-order
FD probes a 6th derivative, so the truncation floor sits far above machine
precision (the same pathology as gam#979). A nested dual evaluates the SAME
single-source program by a DIFFERENT composition ordering (two nested
second-order sweeps instead of one fourth-order sweep), so its
∂²_a ∂²_b channel is a truncation-free, hand-oracle-free cross-check of the
Jet4 bidirectional block.
The construction is standard forward-over-forward automatic differentiation;
its correctness is pinned channel-for-channel against the engine
crate::jet_tower::Tower4 on smooth programs (see the module tests).
Structs§
- Dual2
- A single-direction second-order jet over the field
S: valuev, first derivativeg, second derivativeh, all with respect to ONE seeded direction. Nest it (Dual2<Dual2<f64>>) for a second, independent direction.
Traits§
- JetField
- Minimal scalar field a
Dual2can be built over. Implemented byf64(the base case) and byDual2itself (the nesting case). Every operation mirrors thecrate::jet_tower::Tower4/crate::jet_scalar::JetScalarFaà di Bruno convention exactly, so a program written againstJetFieldevaluates identically on the engine tower and on a nested dual. - JetField
Const - A
JetFieldthat isCopyand can be built from a real constant with every derivative channel zero. The nested-dual oracle (Dual2over aCopyleaf) needs a dimensionless constructor; the runtime-pVec-backed flex jets deliberately do NOT satisfy this (their constant needs a primary count), so it lives on this subtrait rather than the shared algebra base.
Type Aliases§
- Dual22
- A
Dual2<Dual2<f64>>seeded with independent directionsa(outer) andb(inner): valuex, unit first derivative along both requested directions.p0should be seeded(a=1, b=0)andp1(a=0, b=1)for a two-primary program (mirrorsTower4::variable(x, 0)/Tower4::variable(x, 1)).