Skip to main content

Compute numerical derivatives.

Project description

https://img.shields.io/pypi/v/jacobi https://img.shields.io/badge/github-docs-success https://img.shields.io/badge/github-source-blue

Fast numerical derivatives for real analytic functions with arbitrary round-off error.

Features

  • Robustly compute the generalised Jacobi matrix for an arbitrary real analytic mapping of ℝⁿ → ℝⁱ¹ × … × ℝⁱⁿ

  • Derivative is computed to specified accuracy or until precision of function is reached

  • Algorithm based on John D’Errico’s DERIVEST: flawlessly works even with functions that have large round-off error

  • Up to 1200x faster than numdifftools at equivalent precision

  • Returns error estimates for derivatives

  • Supports calculation of derivative up to target precision (speed-up)

  • Supports arbitrary auxiliary function arguments

  • Lightweight package, only depends on numpy

Example

from matplotlib import pyplot as plt
import numpy as np
from jacobi import jacobi


# function of one variable with auxiliary argument; returns a vector
def f(p, x):
    y = p + x
    return np.sin(y) / y


x = np.linspace(-10, 10, 1000)
fx = f(0, x)
fdx, fdex = jacobi(f, 0, x)

plt.plot(x, fx, label="f(x) = sin(x) / x")
plt.plot(x, fdx, ls="--", label="f'(x)")
plt.legend()
doc/_static/example.svg

Comparison to numdifftools

Speed

Jacobi makes better use of vectorised computation than numdifftools.

doc/_static/speed.svg

Precision

The machine precision is indicated by the dashed line.

doc/_static/precision.svg

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

jacobi-0.1.4.tar.gz (425.3 kB view hashes)

Uploaded Source

Built Distribution

jacobi-0.1.4-py3-none-any.whl (6.2 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