Compute numerical derivatives.
Project description
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()
Comparison to numdifftools
Speed
Jacobi makes better use of vectorised computation than numdifftools.
Precision
The machine precision is indicated by the dashed line.
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 Distribution
Built Distribution
File details
Details for the file jacobi-0.1.4.tar.gz
.
File metadata
- Download URL: jacobi-0.1.4.tar.gz
- Upload date:
- Size: 425.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72e859ce75c80ba1cb9e735a1ae2c0ee34e77c52d401cd3e6a092a73d4c6ddf9 |
|
MD5 | c45725633b38c0ded42e585c90bac15f |
|
BLAKE2b-256 | 57cc0db1a87c44b6961cabee00bd802222397848ce7a1a31715e15eb94dfc30f |
File details
Details for the file jacobi-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: jacobi-0.1.4-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52873f672bc3c9968e25afc68f9be027a13f92b70c8e8223dccaaeb4b8678f66 |
|
MD5 | c5b4f2b6e4e3a70b10b90adbd89d31d6 |
|
BLAKE2b-256 | 88521efefeaf117463168aec9a4cb2f376d2215a0c4ec5240d341b95d5a64065 |