dual R6 class for forward-mode automatic differentiation
dual.Rddual R6 class for forward-mode automatic differentiation
dual R6 class for forward-mode automatic differentiation
Details
Represents a dual number (primal, tangent) for computing directional derivatives via forward-mode AD. When combined with reverse-mode (value), enables Hessian computation via forward-over-reverse.
Forward-mode AD propagates derivatives alongside values during the forward pass. For a function f(x), setting tangent(x) = 1 gives f'(x) in the tangent of the output.
For Hessian computation (forward-over-reverse):
primal is a
valueobject (for reverse-mode gradient)tangent is also a
valueobject (tracks d/dx of the gradient)After backward() on primal, tangent of grad gives Hessian entries
Public fields
primalThe function value (can be numeric or value object)
tangentThe directional derivative (can be numeric or value object)