N-dimensional complex step and finite step differentiation, and Newton's method.
Project description
ndmath
ndmath is a Python library for N-dimensional complex step and finite step differentiation, and Newton's method.
Installation
Use the package manager pip to install ndmath.
pip install ndmath
Examples
Calculating the Jacobian at a point:
import ndmath
ndmath.complexGrad(lambda x : x[0]**2+x[1], [1,2]) # returns array([2., 1.])
ndmath.finiteGrad(lambda x : x[0]**2+x[1], [1,2], 10**-7) # returns array([2.0000001, 1.])
Using the root-finding Newton's method:
def func(x):
return [(x[1]-3)**2+x[0]-5, 2*x[1]+x[0]**3]
def fprime(x):
return ndmath.complexGrad(func, x)
x0 = [0,0] #initial estimate
ndmath.nDimNewton(func, x0, fprime) # returns array([-1.02890183, 0.54461778])
Dependencies
Contributing
Pull requests are welcome. Feel free to open an issue first to discuss what you would like to change.
License
References
- Martins, J. R. R. A., Sturdza, P., and Alonso, J. J., 2003, "The Complex-Step Derivative Approximation," ACM Trans. Math. Software, 29(3), pp. 245–262.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ndmath-0.0.5-py3-none-any.whl.
File metadata
- Download URL: ndmath-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79e616adcfda3e4a5382c305de6cdb9c30ce4257c9e4c5065d1954dbee896302
|
|
| MD5 |
66607a04b742a356591edf2d7967f134
|
|
| BLAKE2b-256 |
c9a201d50dd9933ca1e5a4981162068867252ea2068931202e7d54a0570bf469
|