div_frule

Function div_frule 

Source
pub fn div_frule<S: ScalarAd>(x: S, y: S, dx: S, dy: S) -> (S, S)
Expand description

Forward rule for div.

Returns (primal, tangent).

When y is zero, the derivative produces NaN/Inf following IEEE 754 semantics, consistent with standard AD behavior for division by zero.

ยงExamples

use chainrules::div_frule;

let (y, dy) = div_frule(8.0_f64, 2.0_f64, 0.5_f64, 0.25_f64);
assert_eq!(y, 4.0_f64);
assert!((dy + 0.25_f64).abs() < 1e-12);