option-pricing 0.1.4

Option pricing: Black-Scholes, implied volatility with Newton-Raphson, Halley methods
Documentation
/// error function
pub fn erf(x: f32) -> f32 {
    let sign = x.signum();
    let x_abs = x.abs();

    let a1: f32 = 0.254829592;
    let a2: f32 = -0.284496736;
    let a3: f32 = 1.421413741;
    let a4: f32 = -1.453152027;
    let a5: f32 = 1.061405429;
    let p: f32 = 0.3275911;

    // A&S 7.1.26
    let t = 1.0 / (1.0 + p * x_abs);
    let y = 1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * (-x * x).exp();

    sign * y
}

/// standard normal cumulative distribution
pub fn cdf(z: f32) -> f32 {
    if z < -1e5 {
        0.0
    } else if z > 1e5 {
        1.0
    } else {
        0.5 * (1.0 + erf(z / 2.0f32.sqrt()))
    }
}

const PI: f32 = 3.1415926535897931f32;

/// standard normal probability density
pub fn pdf(z: f32) -> f32 {
    return (1.0 / ((2.0 * PI).sqrt())) * (-0.5 * z * z).exp();
}