Crate dual_num [] [src]

Dual Numbers

This is a dual number implementation scavenged from other dual number libraries and articles around the web, including:

The difference being is that I have checked each method against Wolfram Alpha for correctness and will keep this implementation up to date and working with the latest stable Rust and num-traits crate.

Usage

extern crate dual_num;

use dual_num::{DualNumber, Float, differentiate};

fn main() {
    // find partial derivative at x=4.0
    println!("{:.5}", differentiate(4.0f64, |x| {
        x.sqrt() + DualNumber::from_real(1.0)
    })); // 0.25000
}

Structs

DualNumber

Dual Number structure

Traits

Float

Generic trait for floating point numbers

FloatConst
Num

The base trait for numeric types, covering 0 and 1 values, comparisons, basic numeric operations, and string conversion.

One

Defines a multiplicative identity element for Self.

Zero

Defines an additive identity element for Self.

Functions

differentiate

Evaluates the function using dual numbers to get the partial derivative at the input point

Type Definitions

DualNumberF32

Convenience type

DualNumberF64

Convenience type