Skip to main content

implicit_hvp

Function implicit_hvp 

Source
pub fn implicit_hvp<F: Float>(
    tape: &mut BytecodeTape<F>,
    z_star: &[F],
    x: &[F],
    v: &[F],
    w: &[F],
    num_states: usize,
) -> Option<Vec<F>>
Expand description

Compute the implicit Hessian-vector-vector product d²z*/dx² · v · w (m-vector).

Given a residual tape F: R^(m+n) → R^m with F(z*, x) = 0, computes the second-order sensitivity by differentiating the IFT identity twice:

F_z · h + [ṗ^T · Hess(F_i) · ẇ]_i = 0

where ṗ = [dz*/dx · v; v], ẇ = [dz*/dx · w; w], and h = d²z*/dx² · v · w.

Uses nested Dual<Dual<F>> forward passes to compute the second-order correction in a single O(tape_length) pass per direction pair.

Returns None if F_z is singular.