Accurate derivative information is central to sensitivity analysis and optimization, yet standard finite differences can lose many digits when the step size is small because of subtractive cancellation. Complex-step differentiation largely resolves this issue for first derivatives, but robust second derivatives and mixed partials remain delicate: several practical complex-step variants for f′′ still subtract nearly equal quantities, and quaternion-step rules are often presented as separate constructions. We develop a unified slice-based framework that extracts first and second derivatives from a single evaluation by projecting algebraic coefficients in commutative subalgebras of the complexified quaternions. First, we formulate a directional quaternion-steprule parameterized by an arbitrary unit pure quaternion u and provide an explicit projection operator that makes the underlying complex slice Cu≃C transparent; the resulting first-derivative formula is rotation invariant and recovers classical j-step and planar (j,k)-step rules as special cases. Second, we construct a bicomplex double-step calculus in the commuting imaginary units i and u and show that one evaluation at z+(i+u)h separates derivative information into distinct coefficients, with the iu-component equal to h2f′′(z)+O(h4), giving a subtraction-free O(h2) approximation of f′′. For bivariate analytic functions we additionally derive one-shot identities for fx, fy, and fxy from f(x+uh,y+ih) and supply practical extraction identities, step-size guidance for h2-scaled coefficients, and branch-consistency diagnostics for non-entire functions. The “cancellation-free” property here refers to avoiding the subtraction of nearly equal real quantities at the level of the differentiation formula; in floating-point arithmetic, coefficient extraction and the 1/h2 scaling for second-order quantities still interact with roundoff, and we quantify the resulting stable regimes numerically.
Ji Eun Kim (Fri,) studied this question.