Skip to main content

numericalderivative

What is it?

The goal of this project is to compute the derivative of a function using finite difference formulas. The difficulty with these formulas is that it must use a step which must be neither too large (otherwise the truncation error dominates the error) nor too small (otherwise the condition error dominates). For this purpose, it provides exact methods (based on the value of higher derivatives) and approximate methods (based on function values). Furthermore, the module provides finite difference formulas for the first, second, third or any arbitrary order derivative of a function. Finally, this package provides 15 benchmark problems for numerical differentiation.

This module makes it possible to do this:

import math
import numericalderivative as nd

def scaled_exp(x):
    alpha = 1.0e6
    return math.exp(-x / alpha)


h0 = 1.0e5  # This is the initial step size
x = 1.0e0
algorithm = nd.SteplemanWinarsky(scaled_exp, x)
h_optimal, iterations = algorithm.compute_step(h0)
f_prime_approx = algorithm.compute_first_derivative(h_optimal)

Documentation & references

Authors

  • Michaël Baudin, 2024

Installation

To install from Github:

git clone https://github.com/mbaudin47/numerical_derivative.git
cd numerical_derivative
python setup.py install

To install from Pip:

pip install numericalderivative

References

  • Gill, P. E., Murray, W., Saunders, M. A., & Wright, M. H. (1983). Computing forward-difference intervals for numerical optimization. SIAM Journal on Scientific and Statistical Computing, 4(2), 310-321.
  • Adaptive numerical differentiation R. S. Stepleman and N. D. Winarsky Journal: Math. Comp. 33 (1979), 1257-1264
  • Dumontet, J., & Vignes, J. (1977). Détermination du pas optimal dans le calcul des dérivées sur ordinateur. RAIRO. Analyse numérique, 11 (1), 13-25.

Roadmap

  • GillMurraySaundersWright: update to setup from absolute precision instead of relative precision. This is because the current computation based on the relative precision cannot work if the function value at point x is zero.

  • Implement the method of:

    Shi, H. J. M., Xie, Y., Xuan, M. Q., & Nocedal, J. (2022). Adaptive finite-difference interval estimation for noisy derivative-free optimization. SIAM Journal on Scientific Computing, 44(4), A2302-A2321.

  • Implement a method to compute the absolute error of evaluation of the function f, for example :

    J. J. Moré and S. M. Wild, Estimating computational noise, SIAM Journal on Scientific Computing, 33 (2011), pp. 1292–1314.

  • Make sure that the API help page of each method has a paragraph on the cases of failure. Also, add a paragraph on an alternative method using compute_step of F.D. formula, with some extra assumption on a higher derivative.

Metadata

Release files for numericalderivative 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for numericalderivative 0.3
File Interpreter ABI Platform Actions
numericalderivative-0.3-py3-none-any.whl Python 3 none any Details for numericalderivative-0.3-py3-none-any.whl

Release files / numericalderivative-0.3-py3-none-any.whl

Download URL numericalderivative-0.3-py3-none-any.whl
Size 52.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5092e489d655020a150d2169a234fd0cf041a94e99553a5a45ea807ca94e939d
BLAKE2b-256 checksum
How to use checksums
3188e300811f561cab7b2184474a665ed830f10cf0a604bbccbe60ecdc966618
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.0

Security for numericalderivative 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page