Implements forward-mode automatic differentiation using dual numbers with S4 classes. Supports exact arbitrary-order derivatives through recursive nesting of duals, with high-level functions for computing gradients, Hessian matrices, and Jacobians of arbitrary functions.

Core Types

dual

Constructor for dual numbers.

dual_variable

Shorthand for dual(x, 1).

dual_constant

Shorthand for dual(x, 0).

dual_vector

Container for indexable dual vectors.

Accessors

value

Extract the primal value.

deriv

Extract the derivative component.

Higher-Order Derivatives

dual_variable_n

Create a dual seeded for n-th order differentiation.

deriv_n

Extract the k-th derivative from a nested dual result.

differentiate_n

Compute f(x) and all derivatives up to order n.

Multi-Parameter Derivatives

D

Composable total derivative operator. D(f) returns the derivative function; apply k times for k-th order tensors.

gradient

Gradient of a scalar-valued function.

hessian

Hessian matrix of a scalar-valued function.

jacobian

Jacobian matrix of a vector-valued function.

References

Baydin, A. G., Pearlmutter, B. A., Radul, A. A., & Siskind, J. M. (2018). Automatic differentiation in machine learning: a survey. Journal of Machine Learning Research, 18(153), 1–43.

See also

Related CRAN packages: dual, numDeriv, madness

Author

Maintainer: Alexander Towell queelius@gmail.com (ORCID)