num-dual
Generalized, recursive, scalar and vector (hyper) dual numbers for the automatic and exact calculation of (partial) derivatives. Including bindings for python.
Installation and Usage
Python
The python package can be installed directly from PyPI:
pip install num_dual
Rust
Add this to your Cargo.toml:
[]
= "0.13"
Example
Python
Compute the first and second derivative of a scalar-valued function.
return /
, , =
Rust
This example defines a generic function that can be called using any (hyper) dual number and automatically calculates derivatives.
use *;
use SMatrix;
Documentation
- You can find the documentation of the rust crate here.
- The documentation of the python package can be found here.
Python
For the following commands to work you have to have the package installed (see: installing from source).
cd docs
make html
Open _build/html/index.html in your browser.
Further reading
If you want to learn more about the topic of dual numbers and automatic differentiation, we have listed some useful resources for you here:
- Initial paper about hyper-dual numbers: Fike, J. and Alonso, J., 2011
- Website about all topics regarding automatic differentiation: autodiff.org
- Our paper about dual numbers in equation of state modeling: Rehner, P. and Bauer, G., 2021
Cite us
If you find num-dual useful for your own scientific studies, consider citing our publication accompanying this library.
@ARTICLE{rehner2021,
AUTHOR={Rehner, Philipp and Bauer, Gernot},
TITLE={Application of Generalized (Hyper-) Dual Numbers in Equation of State Modeling},
JOURNAL={Frontiers in Chemical Engineering},
VOLUME={3},
YEAR={2021},
URL={https://www.frontiersin.org/article/10.3389/fceng.2021.758090},
DOI={10.3389/fceng.2021.758090},
ISSN={2673-2718}
}