div_rrule

Function div_rrule 

Source
pub fn div_rrule<S: ScalarAd>(x: S, y: S, cotangent: S) -> (S, S)
Expand description

Reverse rule for div.

Returns cotangents with respect to (x, y).

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

ยงExamples

use chainrules::div_rrule;

let (dx, dy) = div_rrule(8.0_f64, 2.0_f64, 1.0_f64);
assert_eq!(dx, 0.5_f64);
assert_eq!(dy, -2.0_f64);