Skip to main content

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 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

NumPy

Contributing

Pull requests are welcome. Feel free to open an issue first to discuss what you would like to change.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndmath-0.0.3.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

ndmath-0.0.3-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page