- use the Python 3 (Ubuntu Linux) kernel or SageMath 7.4
- https://pythonhosted.org/ad/#

1

In [1]:

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

2

In [2]:

import ad ad.__version__

3

'1.3.2'

In [3]:

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

4

ad(3)

In [4]:

sin(2*x)

5

ad(0.9092974268256817)

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

6

In [5]:

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

7

-0.8322936730942848

In [6]:

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

8

-3.637189707302727

In [7]:

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

9

-0.9999999999997864

In [ ]:

10