--- 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<I: Instance<Domain>>(&self, x: I) -> Self::DerivativeDomain; + /// Calculate differential and value at `x` + fn apply_and_differential<I: Instance<Domain>>( + &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<I: Instance<X>>(&self, x: I) -> Self::Derivative; + + fn apply_and_differential_impl<I: Instance<X>>( + &self, + x: I, + ) -> (Self::Codomain, Self::Derivative) + where + Self: Mapping<X>, + { + x.eval_ref(|xo| (self.apply(xo), self.differential_impl(xo))) + } } impl<T, Domain> DifferentiableMapping<Domain> for T @@ -126,6 +144,14 @@ self.differential_impl(x) } + #[inline] + fn apply_and_differential<I: Instance<Domain>>( + &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 } }