diffop only.Expand description
Arbitrary differential operator evaluation via jet coefficients.
Evaluate any mixed partial derivative of a recorded tape by constructing higher-order Taylor jets with carefully chosen input coefficients. A single forward pushforward extracts the derivative from a specific output jet coefficient, scaled by a known prefactor from the multivariate Faa di Bruno formula.
§How it works
For a function u: R^n -> R recorded as a BytecodeTape, we want to
compute an arbitrary mixed partial:
∂^Q u / (∂x_{i₁}^{q₁} ... ∂x_{iT}^{qT})The method parameterises a curve g(t) = u(x₀ + v⁽¹⁾t + v⁽²⁾t²/2! + ...)
where each active variable is assigned a distinct polynomial “slot” j_t,
with coeffs[j_t] = 1/j_t! for that variable’s input. The output jet
coefficient at index k = Σ j_t · q_t then equals the target derivative
divided by a known prefactor.
§Usage
use echidna::diffop::{JetPlan, MultiIndex};
// Record a tape
let (tape, _) = echidna::record(|x| x[0] * x[0] * x[1], &[1.0, 2.0]);
// Plan: compute ∂²u/∂x₀² and ∂u/∂x₁
let indices = vec![
MultiIndex::diagonal(2, 0, 2), // d²/dx₀²
MultiIndex::partial(2, 1), // d/dx₁
];
let plan = JetPlan::plan(2, &indices);
// Evaluate
let result = echidna::diffop::eval_dyn(&plan, &tape, &[1.0, 2.0]);
// result.derivatives[0] = 2*x₁ = 4.0 (∂²(x₀²x₁)/∂x₀²)
// result.derivatives[1] = x₀² = 1.0 (∂(x₀²x₁)/∂x₁)§Design
- Plan once, evaluate many:
JetPlan::planprecomputes slot assignments, jet order, and extraction prefactors. Reuse the plan across evaluation points. TaylorDynfor runtime jet order: the required order depends on the differential operator and cannot be known at compile time.- Pushforward groups: Multi-indices that share the same set of active variables are batched into one forward pass. Multi-indices with different active variables get separate pushforwards to avoid slot contamination.
- Panics on misuse: dimension mismatches panic, following existing API conventions.
§Differential Operators
DiffOp represents a linear differential operator L = Σ C_α D^α.
It supports exact evaluation via DiffOp::eval (delegates to JetPlan)
and construction of a SparseSamplingDistribution for stochastic
estimation via stde::stde_sparse (requires
stde feature). Convenience constructors are provided for common operators:
DiffOp::laplacian, DiffOp::biharmonic, DiffOp::diagonal.
Inhomogeneous operators can be decomposed with DiffOp::split_by_order.
Structs§
- DiffOp
- A linear differential operator
L = Σ C_α D^α. - Diff
OpResult - Result of evaluating a differential operator via jet coefficients.
- JetPlan
- Immutable plan for jet evaluation. Constructed once, reused across points.
- Multi
Index - A multi-index specifying which mixed partial derivative to compute.
- Sparse
JetEntry Ref - Read-only view of a [
SparseJetEntry] for use bystde_sparse. - Sparse
Sampling Distribution - Pre-computed discrete distribution over sparse k-jets for STDE.
Functions§
- eval_
dyn - Evaluate a differential operator plan using
TaylorDyn(runtime jet order). - hessian
- Compute the full Hessian (all second-order partial derivatives).
- mixed_
partial - Compute a single mixed partial derivative (plans + evaluates in one call).