Harvard CS207 Automatic Differentiation Project


License
MIT
Install
pip install AnnoDomini==1.0

Documentation

Anno Domini License: MIT Build Status Coverage Status Documentation Status

Anno Domini is equivalent to Automatic Differentiation because they have the same abbreviation (AD).

Quick Start

Installation

$ pip install virtualenv  # If Necessary
$ virtualenv venv
$ source venv/bin/activate
$ pip install numpy
$ pip install AnnoDomini
$ python
>>> import AnnoDomini.AutoDiff as AD
>>> x = AD.AutoDiff(3.0)  # Automatically evaluate dx/dx at x=3.0
>>> print(x)
====== Function Value(s) ======
3.0
===== Derivative Value(s) =====
1.0
>>> quit()
$ deactivate

Use Case 1: Single Variable, Single Function

>>> x = AD.AutoDiff(1.5)
>>> f = x**2 + 2*x + 1  # Automatically evaluate df/dx at x=3.0
>>> print(f)
====== Function Value(s) ======
6.25
===== Derivative Value(s) =====
5.0

Use Case 2: Multiple Variables, Single Function

>>> x = AD.AutoDiff(3., [1., 0.])
>>> y = AD.AutoDiff(2., [0., 1.])
>>> f = x*y  # Evaluate J=[df/dx, df/dy] at x=3.0 and y=2.0
>>> print(f)
====== Function Value(s) ======
6.0
===== Derivative Value(s) =====
[2. 3.]

Use Case 3: Single Variable, Multiple Functions

>>> x = AD.AutoDiff(3., 1.)
>>> f1 = x**2
>>> f2 = 2*x
>>> print(AD.AutoDiff([f1, f2]))  # Evaluate J=[df1/dx, df2/dx] at x=3.0
====== Function Value(s) ======
[9. 6.]
===== Derivative Value(s) =====
[6. 2.]

Use Case 4: Multiple Variables, Multiple Functions

>>> x = AD.AutoDiff(3., [1., 0.])
>>> y = AD.AutoDiff(2., [0., 1.])
>>> f1 = x+y
>>> f2 = x*y
>>> print(AD.AutoDiff([f1, f2]))  # Evaluate J=[[df1/dx, df1/dy], [df2/dx, df2/dy]] at x=3.0 and y=2.0
====== Function Value(s) ======
[5. 6.]
===== Derivative Value(s) =====
[[1. 1.]
 [2. 3.]]

More Resources

Documentation: https://cs207-finalproject-group15.readthedocs.io/en/latest/

PyPI: https://pypi.org/project/AnnoDomini/

Authors (CS207 Group 15):