#dual #number #hyperdual #multidimentional #autodifferentiate

hyperdual

Fully-featured Dual Number implementation with features for automatic differentiation of multivariate vectorial functions

5 releases

Uses old Rust 2015

0.3.4 Feb 8, 2020
0.3.3 Oct 31, 2019
0.3.2 Oct 3, 2019
0.3.1 Jul 16, 2019
0.3.0 Jul 16, 2019

#22 in #number

Download history 12/week @ 2020-04-18 22/week @ 2020-04-25 22/week @ 2020-05-02 14/week @ 2020-05-09 18/week @ 2020-05-16 15/week @ 2020-05-23 21/week @ 2020-05-30 5/week @ 2020-06-06 13/week @ 2020-06-13 11/week @ 2020-06-20 12/week @ 2020-06-27 10/week @ 2020-07-04 10/week @ 2020-07-11 4/week @ 2020-07-18 9/week @ 2020-07-25 3/week @ 2020-08-01

87 downloads per month
Used in nyx-space

MIT license

33KB
1K SLoC

hyperdual Build Status

Fully-featured Dual Number implementation with features for automatic differentiation of multivariate vectorial functions into gradients.

Usage

extern crate hyperdual;

use hyperdual::{Dual, Hyperdual, Float, differentiate, U3};

fn main() {
    // find partial derivative at x=4.0
    let univariate = differentiate(4.0f64, |x| x.sqrt() + Dual::from_real(1.0));
    assert!((univariate - 0.4500).abs() < 1e-16, "wrong derivative");

    // find the partial derivatives of a multivariate function
    let x: Hyperdual<f64, U3> = Hyperdual::from_slice(&[4.0, 1.0, 0.0]);
    let y: Hyperdual<f64, U3> = Hyperdual::from_slice(&[5.0, 0.0, 1.0]);

    let multivariate = x * x + (x * y).sin() + y.powi(3);
    assert!((res[0] - 141.91294525072763).abs() < 1e-13, "f(4, 5) incorrect");
    assert!((res[1] - 10.04041030906696).abs() < 1e-13, "df/dx(4, 5) incorrect");
    assert!((res[2] - 76.63232824725357).abs() < 1e-13, "df/dy(4, 5) incorrect");
}
Previous Work

Dependencies

~3MB
~60K SLoC