# Automatic Differentiation on CoCalc

In :
from ad import adnumber

In :
import ad

'1.3.2'
In :
x = adnumber(1)
print(2*x + 1)

In :
sin(2*x)


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

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

-0.8322936730942848
In :
y.d2(x)  # d2y/dx2 at x=1

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

-0.9999999999997864
In [ ]:
{"ft_lang_label":"__label__en","ft_lang_prob":0.782962,"math_prob":0.9190402,"size":386,"snap":"2020-45-2020-50","text_gpt3_token_len":131,"char_repetition_ratio":0.12041885,"word_repetition_ratio":0.0,"special_character_ratio":0.35751295,"punctuation_ratio":0.12222222,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9886306,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-20T02:40:01Z\",\"WARC-Record-ID\":\"<urn:uuid:320bd831-a96e-4da5-8dff-c5f1e293be62>\",\"Content-Length\":\"20414\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8f7538cf-65ba-4705-aea4-492823b79cfe>\",\"WARC-Concurrent-To\":\"<urn:uuid:2b28e0ba-96c6-49e5-9ff6-726d92c4839d>\",\"WARC-IP-Address\":\"104.22.1.102\",\"WARC-Target-URI\":\"https://share.cocalc.com/share/b9bacd7b-6cee-402c-88ed-9d74b07f29a1/ad.ipynb?viewer=embed\",\"WARC-Payload-Digest\":\"sha1:A7CBFNOREZ6WSA5VHGIF46NDQ2AMUQ43\",\"WARC-Block-Digest\":\"sha1:BTO5YFR6ZWBS6KX7XH5N2TLSVCQ3VHUL\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107869785.9_warc_CC-MAIN-20201020021700-20201020051700-00350.warc.gz\"}"}