Status: stub — scaffold cells only; expand before relying on this notebook for a course offering.
Compare a hand derivative to automatic differentiation when PyTorch is available.
import numpy as np
w, t = 2.0, 0.3
print('analytic', w * np.cos(w * t))
try:
import torch
tt = torch.tensor(t, requires_grad=True)
f = torch.sin(w * tt)
f.backward()
print('autograd', float(tt.grad))
except ImportError:
print('Install PyTorch in the course env for AD practice.')