from ad import adnumber from ad.admath import * # sin(), etc.

import ad ad.__version__

x = adnumber(1) print(2*x + 1)

sin(2*x)

So far, there shouldnâ€™t be anything unexpected, but first and second derivatives can now be accessed through intuitive methods:

y = sin(2*x) y.d(x) # dy/dx at x=1

y.d2(x) # d2y/dx2 at x=1

z = adnumber(3.141592) y2 = sin(z) y2.d(z) # dy/dx1 at approximately pi