Skip to main content

decay_constant_from_half_life

Function decay_constant_from_half_life 

Source
pub fn decay_constant_from_half_life(half_life: f64) -> Option<f64>
Expand description

Computes a decay constant from a half-life.

Formula: lambda = ln(2) / t_half.

Returns None when half_life is not positive and finite, or when the computed decay constant is not finite.

ยงExamples

use use_nuclear::{decay_constant_from_half_life, LN_2};

let decay_constant =
    decay_constant_from_half_life(10.0).ok_or("expected valid decay constant")?;

assert!((decay_constant - (LN_2 / 10.0)).abs() < 1.0e-12);