import algopy
import numpy as np
import matplotlib.pyplot as plt
import scipy.optimize as op
%matplotlib inline
def func(x):
""" A function that depends on a list of inputs x """
x1 = x[0]
x2 = x[1]
return np.sin(x1) + x1*x2
# end def func
cg = algopy.CGraph()
cg.trace_on()
x = algopy.Function([0,0])
y = func(x)
cg.trace_off()
cg.independentFunctionList = [x]
cg.dependentFunctionList = [y]
cg.gradient([0,0])
cg.plot("ad_algopy_compute_graph.png")