Arithmetic for nested quotient rules #
Checked operations retain range-loss information until the complete quotient has been evaluated.
The cold path evaluates the original finite coefficient trees over Rat, then rounds each
coefficient through FloatLib to the requested format. The same algebra can carry partial
enclosures for compound expressions without duplicating its product and quotient rules.
Quotient replay alone cannot recover information lost before its inputs were formed.
Coefficients in n commuting square-zero variables, with a chosen scalar carrier.
- scalar {α : Type} : α → Coefficients α 0
- dual {α : Type} {n : ℕ} : Coefficients α n → Coefficients α n → Coefficients α (n + 1)
Instances For
Instances For
Constant coefficient, obtained by setting all square-zero variables to zero.
Instances For
Add corresponding coefficients using the chosen leaf arithmetic.
Instances For
Subtract corresponding coefficients using the chosen leaf arithmetic.
Instances For
Multiply coefficient trees using the product rule at each square-zero extension.
Instances For
Divide coefficient trees. Rational callers check the primal denominator first; partial enclosure arithmetic propagates a failed or zero-crossing divisor at each leaf.
Instances For
Change the leaf representation without changing the differentiation directions.
Instances For
Convert every coefficient, propagating a failed conversion.
Instances For
A constant has zero coefficients in every differentiation direction.
Instances For
Lift scalar exponential evaluation through the existing coefficient product rule.
Instances For
Operations used inside one complete quotient, together with finite coefficient conversion.
Internal byte flags record nonfinite or subnormal results, including a nonzero product or quotient rounded to zero. Zero means no range loss; recursive carriers combine flags with bitwise OR. The checked-operation entrypoints expose the same Boolean result without converting at each internal node. Unsupported carriers use the ordinary operations and do not supply a conversion.
- supported : Bool
- depth : ℕ
- encode : α → Option (QuotientCoefficients (depth α))
- decode : QuotientCoefficients (depth α) → Option α
- copyPrimal : α → α → α
Copy the scalar primal's native sign of zero after replaying derivative coefficients.
Instances
Instances For
Replay only finite input trees with an invertible denominator.
Only coefficient conversion crosses this cold boundary, leaving the checked arithmetic operations available for specialization in the caller.
Instances For
Native constants and rational rounding, selected by the scalar type.
- zero : α
- minNormal : α
- negMinNormal : α
- round : ℚ → α
Round a rational once to the native scalar type.
Instances
Instances For
Instances For
Instances For
Range flags for the actual native product z = x * y, using native zero equality.
The open subnormal interval includes zero; nonzero inputs detect a product rounded to zero.
This formula requires the actual product, not an independently supplied third value.
Instances For
Range flags for the actual native quotient z = x / y, using native zero equality.
A zero denominator already makes the result nonfinite. A zero or subnormal result with a
nonzero numerator requires replay. This formula assumes z is the actual division result.
Instances For
Instances For
Instances For
Instances For
Instances For
FloatLib exception status plus the stricter range predicate needed by a nested quotient.
IEEE underflow requires inexactness. An exact subnormal intermediate must also trigger replay, since subsequent multiplication or division can lose coefficients. Ordinary inexact rounding alone does not trigger replay.
Instances For
Configured values with IEEE exceptional encoding use FloatLib's nearest-even operations and exact finite decoder, including custom exponent biases. Status is computed on the descriptor model and repacked through the codec, independently of the selected arithmetic backend.
The complete derivative tree is replayed by the recursive Dual instance. Every coefficient is
rounded independently to the original descriptor and storage plan, including formats wider than
binary64. Finite-only encodings are not enabled: their saturation policy would require a separate
derivative contract. True coefficients outside the IEEE range may still round to zero or infinity.