#root #newton #calculate #wikipedia #function

newton-raphson

Calculate roots of functions using the Newton-Raphson method

1 unstable release

Uses old Rust 2015

0.1.0 Jun 6, 2016

#10 in #newton

MIT license

3KB

newton-raphson: finder of roots

Build Status

This crate is a minimal implementation of the Newton-Raphson method for determining the roots of functions; as described at Wikipedia


lib.rs:

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

Examples

[Solution of cos(c) = x^3^] (https://en.wikipedia.org/wiki/Newton%27s_method#Solution_of_cos.28x.29_.3D_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));

No runtime deps