Crate newton_raphson [] [src]

A minimal module for calculating roots using the Newton-Raphson method, as described by Wikipedia

Examples

Solution of cos(c) = x3^

use std::f64;
use newton_raphson::find_root;
fn cosx(x: f64) -> f64 {
    x.cos() - (x * x * x)
}

fn cosx_d(x: f64) -> f64 {
    -x.sin() - 3.0 * (x * x)
}

assert_eq!(0.8654740331016144, find_root(cosx, cosx_d, 0.5, 6));

Functions

find_root

Finds the root of the function f

iteration

Runs through one iteration of the Newton-Raphson method