std/gradient
Automatic differentiation: the derivative of a function written in ordinary arithmetic, computed alongside its value and exact to the scalar's own precision, with no step size and no symbolic algebra.
Dual is the forward mode. It carries a value and the rate at which that value changes, and because it is itself a
Real it runs through every function that is generic over Real - geometry, animation, physics - without that
function being written for it. The package is pure TorbScript: no foreign functions, and no dependency on
std/tensor.
Modules
std/gradient/dual[Dual], a value together with the rate at which it changes, and [derivative], the one-call form of forward-mode differentiation.
Everything
- fn
derivativeThe derivative of a function of one variable, at a point: the function is called once with a [Dual.variable] and the rate of what it answers is the derivative. - type
DualA number and its rate of change: theprimalpart is the value a plainScalarwould have, and theratepart is how fast that value changes with the variable being differentiated. - extend
Dual<Scalar> with Power<Int64>A whole power: the rate isn * f ** (n - 1) * f', and zero forn == 0.