Skip to main content

Fast, transparent first- and second-order automatic differentiation; loving fork of ad by Abraham Lee / tisimst@gmail.com

Project description

https://travis-ci.org/tisimst/ad.png?branch=master

Overview

The ad package allows you to easily and transparently perform first and second-order automatic differentiation. Advanced math involving trigonometric, logarithmic, hyperbolic, etc. functions can also be evaluated directly using the admath sub-module.

All base numeric types are supported (int, float, complex, etc.). This package is designed so that the underlying numeric types will interact with each other as they normally do when performing any calculations. Thus, this package acts more like a “wrapper” that simply helps keep track of derivatives while maintaining the original functionality of the numeric calculations.

From the Wikipedia entry on Automatic differentiation (AD):

“AD exploits the fact that every computer program, no matter how complicated, executes a sequence of elementary arithmetic operations (addition, subtraction, multiplication, division, etc.) and elementary functions (exp, log, sin, cos, etc.). By applying the chain rule repeatedly to these operations, derivatives of arbitrary order can be computed automatically, and accurate to working precision.”

See the package documentation for details and examples.

Main Features

  • Transparent calculations with derivatives: no or little modification of existing code is needed, including when using the Numpy module.

  • Almost all mathematical operations are supported, including functions from the standard math module (sin, cos, exp, erf, etc.) and cmath module (phase, polar, etc.) with additional convenience trigonometric, hyperbolic, and logarithmic functions (csc, acoth, ln, etc.). Comparison operators follow the same rules as the underlying numeric types.

  • Real and complex arithmetic handled seamlessly. Treat objects as you normally would using the math and cmath functions, but with their new admath counterparts.

  • Automatic gradient and hessian function generator for optimization studies using scipy.optimize routines with gh(your_func_here).

  • Compatible Linear Algebra Routines in the ad.linalg submodule, similar to those found in NumPy’s linalg submodule, that are not dependent on LAPACK. There are currently:

    1. Decompositions

      1. chol: Cholesky Decomposition

      2. lu: LU Decomposition

      3. qr: QR Decomposition

    2. Solving equations and inverting matrices

      1. solve: General solver for linear systems of equations

      2. lstsq: Least-squares solver for linear systems of equations

      3. inv: Solve for the (multiplicative) inverse of a matrix

Installation

You have several easy, convenient options to install the ad package (administrative privileges may be required):

  1. Download the package files below, unzip to any directory, and run python setup.py install from the command-line.

  2. Simply copy the unzipped ad-XYZ directory to any other location that python can find it and rename it ad.

  3. If setuptools is installed, run easy_install --upgrade ad from the command-line.

  4. If pip is installed, run pip install --upgrade ad from the command-line.

  5. Download the bleeding-edge version on GitHub

Contact

Please send feature requests, bug reports, or feedback to Abraham Lee.

Acknowledgements

The author expresses his thanks to :

  • Eric O. LEBIGOT (EOL), author of the uncertainties package, for providing code insight and inspiration

  • Stephen Marks, professor at Pomona College, for useful feedback concerning the interface with optimization routines in scipy.optimize.

  • Wendell Smith, for updating testing functionality and numerous other useful function updates

  • Jonathan Terhorst, for catching a bug that made derivatives of logarithmic functions (base != e) give the wrong answers.

  • GitHub user fhgd for catching a mis-calculation in admath.atan2

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

adce-1.3.3.2.tar.gz (23.0 kB view details)

Uploaded Source

File details

Details for the file adce-1.3.3.2.tar.gz.

File metadata

  • Download URL: adce-1.3.3.2.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.4 CPython/2.7.12

File hashes

Hashes for adce-1.3.3.2.tar.gz
Algorithm Hash digest
SHA256 22c7e17cfa1d6046938f1ab94b09d037c2003c0e8d13430c2346120dcc9489bf
MD5 3ca6d42527816f32827f69e500214c0e
BLAKE2b-256 fff9055bc390ebd6912b662539be2bbc13a5ee843b6d83a3ddc9191b03894589

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