Skip to main content

An automatic differentiation library (support forward and reverse mode)

Project description

EasyDiff Build Status codecov

EasyDiff is an automatic differentiation python library with forward and reverse mode supported. EasyDiff is developed as a Harvard CS207 (19Fall) course project by Group 18: Yang Zhou, Ruby Zhang, Kangli Wu, and Emily Gould. Check our documentation for more details.

How to use CrackAD


Option One: Downloading Using Pip

Get The Package

Simply open your terminal and type the following command:

pip install EasyDiff

Update The Package

To get new releases, paste this into your terminal:

pip install EasyDiff --upgrade

We highly recommend installing the package with pip. Yet, if that doesn't work for you, you can still get our package with the second option below.

Option Two: Downloading From GitHub

Clone the Repository

Clone our GitHub repository and navigate into this directory in your terminal:

git clone

In order to use the CrackAD package, you'll need to create a virtual environment. We recommend conda because it is both a package and environment manager and is language agnostic. Please run the following commands in a terminal:

Create Conda Environment

Create an environment with the command, where env_name is the name of your choice. Since our package requires the NumPy package, we also install it at this step:

conda create --name env_name python numpy

Activate the Environment

To activate the Conda environment just created, run the following line:

source activate env_name


conda activate env_name

Yet, it is possible that the second one doesn't work because conda will complain that the shell hasn't been configured to use conda activate. So we would recommend using the first line.

Install Packages

If you haven't installed NumPy in the first step, or if you ever need to install another package, simply do the following:

conda install numpy

To check whether the installation succeeded, we could list out all installed packages in this environment:

conda list

If the conda install did not work, try pip install:

pip install Numpy

Note that it is suggested to always try conda install first.


To use CrackAD, create a .py file (eg, with the following lines of code:

from import AD
from EasyDiff.var import Var
from EasyDiff.rev_var import Rev_Var
from import AD_Mode
import numpy as np

# test forward mode. 
# give it a function of your choice
func = lambda x,y: Var.log(x) ** Var.sin(y)

# give the initial values to take the derivatives at
ad = AD(vals=np.array([2, 2]), ders=np.array([1, 1]), mode=AD_Mode.FORWARD)

# calculate and print the derivatives
print("Var.log(x) ** Var.sin(y): {}".format(vars(ad.auto_diff(func))))

# test reverse mode. 
func = lambda x,y: Rev_Var.log(x) ** Rev_Var.sin(y)
ad = AD(vals=np.array([2, 2]), ders=np.array([1, 1]), mode=AD_Mode.REVERSE)
print("Rev_Var.log(x) ** Rev_Var.sin(y): {}".format(vars(ad.auto_diff(func))))

Then, you can run the file in a terminal as follows:


Project details

Release history Release notifications

This version


Download files

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

Files for easydiff, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size easydiff-0.0.3-py3-none-any.whl (17.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size easydiff-0.0.3.tar.gz (13.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page