pow_frule

Function pow_frule 

Source
pub fn pow_frule<S: ScalarAd>(x: S, exponent: S, dx: S, dexponent: S) -> (S, S)
Expand description

Forward rule for pow(x, exponent).

When x is zero and exponent is a non-positive real scalar, the exponent-tangent path returns NaN to surface the singularity.

ยงExamples

use chainrules::pow_frule;

let (y, dy) = pow_frule(2.0_f64, 3.0_f64, 1.0, 0.0);
assert_eq!(y, 8.0);
assert!((dy - 12.0).abs() < 1e-12);