1Dual numbers carry the derivative
Extend every number with an infinitesimal part , where . Taylor expansion then stops after one term, so evaluating a function on a dual number returns its value and its exact derivative together:
For the running example, ordinary arithmetic on duals gives
Two numbers per number. Drag . Each operation updates the value part as usual and the ε part by its derivative rule: multiplies by , and the product rule adds .
In tang this is just a type. Code written once over S: Scalar computes values with f64 and derivatives with Dual<f64>, with no tape and no symbolic engine. For many inputs, the same functions trace into a graph instead, and tang-expr runs reverse mode over it.