Skip to main content

Automatic differentiation with dual numbers

Project description

Build Status

Coverage Status


Developed by: Will Claybaugh, Bruce Xiong, Erin Williams
Group #3, CS207 Fall 2018


Autodiff finds the derivatives of a function (to machine precision!) at the same time it finds the value of the function.

import autodiff.autodiff as ad

x = ad.DualNumber('x', 2)
y = ad.DualNumber('y', 3)

out = x/y
out.value # 0.66666, the value of 2 divided by 3
out.derivatives #{x: 1/3, y: -2/(3**2)}, the gradient of x/y at (2,3)

Autodiff works for functions and expressions with any number of inputs. Just pass those functions DualNumbers instead of regular ints/floats (and upgrade any math module functions to their autodiff equvalents)


Autodiff is on PyPi and can be installed using the command pip install AutoDiff-group3. To import, use import autodiff.autodiff as ad.

Autodiff can also be installed by downloading from github. Becuase it has no dependencies, you can simply add the repo folder to your python path (import sys sys.path.insert(0, '/path_to_repo/')) and import as normal.


Using autodiff is very simple:

import autodiff.autodiff as ad

def f(a,b):
    return 3*a/b*ad.sin(a*b+2)

out = f(ad.DualNumber('x',2),ad.DualNumber('y',3))




# get the value and derifative of f at a different point
out = f(ad.DualNumber('x',0),ad.DualNumber('y',1))

A Python 3 notebook containing more in-depth examples and usage is available HERE


Click HERE for full documentation.


Click HERE for a full listing of dependencies.


Click HERE to view our MIT License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for AutoDiff-group3, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size AutoDiff_group3-0.0.6-py3-none-any.whl (24.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size AutoDiff_group3-0.0.6.tar.gz (11.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page