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 ℝⁿ → ℝⁱ¹ × … × ℝⁱⁿ

  • Derivative is either computed to specified accuracy (to save computing time) or until maximum precision of function is reached

  • Algorithm based on John D’Errico’s DERIVEST: 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 arbitrary auxiliary function arguments

  • Lightweight package, only depends on numpy

Planned features

  • Compute the Hessian matrix numerically with the same algorithm

  • Further generalize the calculation to support function arguments with shape (N, K), in that case compute the Jacobi matrix for each of the K vectors of length N

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(dx, x):
    y = x + dx
    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()
https://hdembinski.github.io/jacobi/_images/example.svg

Comparison to numdifftools

Speed

Jacobi makes better use of vectorised computation than numdifftools. Smaller run-time is better (and ratio > 1).

https://hdembinski.github.io/jacobi/_images/speed.svg

Precision

The machine precision is indicated by the dashed line.

https://hdembinski.github.io/jacobi/_images/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.2.0.tar.gz (427.0 kB view details)

Uploaded Source

Built Distribution

jacobi-0.2.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file jacobi-0.2.0.tar.gz.

File metadata

  • Download URL: jacobi-0.2.0.tar.gz
  • Upload date:
  • Size: 427.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for jacobi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d8031e9dee6afc50bb9b30d69a272a8a58008936353f7e67800308c0a4b5b415
MD5 1f9df6b7ccf3ef018d0250184bc21f25
BLAKE2b-256 5b456cfd3f38a3a1e85771c6fb70e42db090a1a7be107b6185d2197dc0e4c03e

See more details on using hashes here.

File details

Details for the file jacobi-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: jacobi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for jacobi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8550ef4b15a5aa5db2a2ec4204f3f615d6486d5ea73c3a5540748fae7ed1d7dd
MD5 6b563950336ba497cada1ddd1b684d79
BLAKE2b-256 19064b4b8f62ad41e84653ce92a1defa61d13e945506fb2b9444e0250a28ce77

See more details on using hashes here.

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