Coding Exercise on Derivatives

Complete this coding exercise on derivatives.

Problem statement

Given the function f(x)=x2+sin(x1/2)+log(x)+exp(cos(x))f(x) = x^2+ \sin(x^{1/2}) + \log(x) + \exp(\cos(x)), calculate its second-order derivative, i.e., 22xf(x)\frac{\partial^2}{\partial^2 x} f(x), at the point x=x0x = x_0. Your implementation should use PyTorch's torch.autograd.grad() utility for calculating derivatives.

To calculate second-order derivatives, you first need to calculate the first-order derivative f(x)x\frac{\partial f(x)}{\partial x} and then differentiate it again with respect to xx. In other words,

Get hands-on with 1200+ tech skills courses.