numdifftools
Solves automatic numerical differentiation problems in one or more variables.
What it is and what it does
Numdifftools is a numerical differentiation library that computes derivatives of any order for scalar and vector functions without requiring symbolic expressions or hand-coded gradients. It uses adaptive finite differences coupled with Richardson extrapolation to achieve high accuracy, and lets you choose between complex-step, central, forward, or backward difference schemes. The library provides high-level interfaces for common tasks like computing Jacobians, Hessians, and directional derivatives, along with error estimates on all results.
The package is built on numpy and scipy and is designed for scientific computing workflows where you need to compute derivatives of functions that are only available as Python callables. It also provides an interface to AlgoPy for algorithmic differentiation when needed. It supports Python 3.10 and later and is actively maintained.
Use it for:
- Compute gradients for optimization algorithms when analytical derivatives are unavailable or expensive to derive.
- Calculate Jacobians for nonlinear least-squares fitting and parameter estimation problems.
- Evaluate Hessian matrices for second-order optimization methods and sensitivity analysis.
- Verify hand-coded derivatives by comparing them against numerical estimates.
- Compute directional derivatives and higher-order partial derivatives for scientific analysis.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Computes numerical derivatives, gradients, Jacobians, Hessians, and higher-order partial derivatives of scalar and vector functions using adaptive finite differences and Richardson extrapolation.
Yes. The package is actively maintained, has no known vulnerabilities, installs cleanly with minimal dependencies, and solves a well-defined problem in numerical computing. It is a good fit if you need to compute derivatives without symbolic math or hand-coding gradients. The permissive BSD license poses no restrictions.
Install
numdifftools on PyPI
pip
pip install numdifftoolsuv
uv add numdifftoolspoetry
poetry add numdifftoolsInstalling numdifftools
Before you install
Low install friction; pure Python wheel with only numpy and scipy as runtime dependencies. Active maintenance with a release 2 days ago and recent commits.
License in practice
Licensed under new BSD (permissive), so you can use it freely in commercial and private projects with minimal restrictions.
Quickstart
pip install numdifftools
import numdifftools as nd
import numpy as np
# Compute first derivative of exp(x) at x=1
fd = nd.Derivative(np.exp)
result = fd(1)
# Compute gradient of sum(x**2)
fun = lambda x: np.sum(x**2)
dfun = nd.Gradient(fun)
grad = dfun([1, 2, 3])
Verify before relying
- Whether the package supports automatic differentiation (AD) modes beyond finite differences, or if AlgoPy integration is optional.
- Performance characteristics for high-dimensional problems or very large Hessians.
- Whether error estimates are always reliable or have known failure modes.
Package facts
| License | new BSD (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — numpy, scipy |
| Maintenance | actively maintained — 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 477,954/month — #6,440 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: numdifftools-0.10.1-py3-none-any.whl
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
autogradAutograd automatically computes derivatives of…
permissive · top 5,000 on PyPI
findiffComputes finite difference numerical…
permissive · top 15,000 on PyPI
sparsediffpySparseDiffPy provides Python bindings to…
permissive · top 5,000 on PyPI
casadiCasADi is a framework for algorithmic…
copyleft · top 5,000 on PyPI
autograd-gammaProvides autograd-compatible derivatives for…
permissive · top 5,000 on PyPI
uncertaintiesPerforms arithmetic and mathematical operations…
permissive · top 5,000 on PyPI
drjitDr.Jit is a just-in-time compiler for…
permissive · top 15,000 on PyPI
TheanoTheano is a Python library for defining,…
permissive · top 15,000 on PyPI
AeroSandboxAeroSandbox is an optimization toolkit for…
permissive · top 15,000 on PyPI
audmathaudmath provides mathematical functions…
permissive · top 15,000 on PyPI