FunctionRacerProblemsRace

The Second Derivative

HardPyTorchPython

Let f be the sum of x² · sin(x) over the elements of x. Return the second derivative of f with respect to each element: the derivative of its derivative. Autograd can differentiate its own result when it is asked to keep the graph of the first pass.

Example 1

x [1.0]
returns [3.0026803]

The second derivative of x² · sin(x) is 2 · sin(x) + 4x · cos(x) - x² · sin(x). At 1 that is 3.0027.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More PyTorch problems