Premium problem79. First and Second Derivative

Hard Locked

For y = x**4 + 2*x**2 at x = value, use autograd to obtain both the first and the second derivative, and return them as the tuple (first, second).

Do not write the derivative formulas yourself. Getting a second derivative means asking for the first with create_graph=True, so the gradient computation is itself part of the graph and can be differentiated again.

Input

2.0

Output

(tensor(40., grad_fn=<AddBackward0>), tensor(52.))

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)