CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Avatar for Testing 18.04.

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Project: Testing 18.04
Path: ad.ipynb
Views: 402
Kernel: Python 3 (Ubuntu Linux)

Automatic Differentiation on CoCalc

from ad import adnumber from ad.admath import * # sin(), etc.
import ad ad.__version__
'1.3.2'
x = adnumber(1) print(2*x + 1)
ad(3)
sin(2*x)
ad(0.9092974268256817)

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
-0.8322936730942848
y.d2(x) # d2y/dx2 at x=1
-3.637189707302727
z = adnumber(3.141592) y2 = sin(z) y2.d(z) # dy/dx1 at approximately pi
-0.9999999999997864