#python-bindings #differentiation #numeric

yanked dualnum

Python bindings for num-dual: Generalized (hyper) dual numbers for the calculation of exact (partial) derivatives

0.2.1 Jul 26, 2021
0.2.0 Jul 26, 2021
0.1.0 Jul 21, 2021

#18 in #differentiation

Download history 9/week @ 2024-03-26 42/week @ 2024-04-02

51 downloads per month

MIT/Apache

33KB
682 lines

dualnum

documentation PyPI version

Python bindings for the num-dual rust crate.

Installation

pip install dualnum

Installation from source

To install from source, you need to have the rust compiler installed.

pip install git+https://github.com/itt-ustutt/dualnum

Sphinx documentation

To build the documentation with sphinx:

maturin develop --release
cd docs
make html
make doctest
firefox _build/html/index.html

Usage

Compute first and second derivative of a scalar valued function.

from dualnum import derive2
import numpy as np

def f(x):
    return np.exp(x) / np.sqrt(np.sin(x)**3 + np.cos(x)**3)

x = derive2(1.5)
result = f(x)
print('f(x)    = {}'.format(result.value))
print('df/dx   = {}'.format(result.first_derivative))
print('d2f/dx2 = {}'.format(result.second_derivative))

Dependencies

~3.5MB
~69K SLoC