diff -r dccf609cd020 -r a5ee4bfb0b87 src/mapping.rs --- a/src/mapping.rs Mon Dec 08 15:23:42 2025 -0500 +++ b/src/mapping.rs Thu Jan 15 16:12:47 2026 -0500 @@ -83,6 +83,14 @@ /// Calculate differential at `x` fn differential>(&self, x: I) -> Self::DerivativeDomain; + /// Calculate differential and value at `x` + fn apply_and_differential>( + &self, + x: I, + ) -> (Self::Codomain, Self::DerivativeDomain) { + x.eval_ref(|xo| (self.apply(xo), self.differential(xo))) + } + /// Form the differential mapping of `self`. fn diff(self) -> Self::Differential<'static>; @@ -108,6 +116,16 @@ /// Compute the differential of `self` at `x`, consuming the input. fn differential_impl>(&self, x: I) -> Self::Derivative; + + fn apply_and_differential_impl>( + &self, + x: I, + ) -> (Self::Codomain, Self::Derivative) + where + Self: Mapping, + { + x.eval_ref(|xo| (self.apply(xo), self.differential_impl(xo))) + } } impl DifferentiableMapping for T @@ -126,6 +144,14 @@ self.differential_impl(x) } + #[inline] + fn apply_and_differential>( + &self, + x: I, + ) -> (T::Codomain, Self::DerivativeDomain) { + self.apply_and_differential_impl(x) + } + fn diff(self) -> Differential<'static, Domain, Self> { Differential { g: MyCow::Owned(self), _space: PhantomData } }