Skip to main content

Automatic differentiation with dual numbers

Project description

Build Status

Coverage Status

AutoDiff

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

Introduction

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

import 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)

Installation

Autodiff can be installed using pip install AutoDiff-group3.

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.

Examples

Using autodiff is very simple:

import sys
sys.path.insert(0, "C:/Users/erina/cs207-FinalProject/")
import 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))

print(out.value)
1.978716

print(out.derivatives['x'])
0.116358

print(out.derivatives['y'])
-1.24157

# 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

Documentation

Click HERE for full documentation.

Dependencies

Click HERE for a full listing of dependencies.

License

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.

Source Distribution

AutoDiff_group3-0.0.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AutoDiff_group3-0.0.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file AutoDiff_group3-0.0.2.tar.gz.

File metadata

  • Download URL: AutoDiff_group3-0.0.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for AutoDiff_group3-0.0.2.tar.gz
Algorithm Hash digest
SHA256 817dfbec1e022e61aef9b9a0eeeee4c81ad9c1384dbd6cfe3f13f6a7a3cccc02
MD5 66a72800a7a3c1f62a4806becd5c4cbb
BLAKE2b-256 0de2c1e1757680c80a5501331672ceeb4d831133e815e04f1e4b7b9922a3eeb1

See more details on using hashes here.

File details

Details for the file AutoDiff_group3-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: AutoDiff_group3-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for AutoDiff_group3-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 97e3cc8e133e7fb5af1fb21b2fbb94bdf6d9b0ce00adfaeeb95d98a212ce574b
MD5 dbd66bc65475c30fb68652a81dad5471
BLAKE2b-256 55980db6987b110ad710c06644ac1cf63407357e5c75052c17d9d6d66b1bd77d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page