Skip to content
DeepForgeby svx
All problems
MediumCalculusca-363

Second Directional Derivative Value

Problem

For a twice differentiable function, the second derivative along a direction v is (v^T H v) / (v^T v), where H is the Hessian at the point.

Given the Hessian as nested rows and a nonzero direction vector, return the second directional derivative.

Hint

Form H v, then dot it with v and normalize by v dot v.

Test cases

case 1
in: [[[1,0],[0,1]],[1,0]]
expected: 1
case 2
in: [[[2,1],[1,2]],[1,1]]
expected: 3
case 3
in: [[[0,1],[1,0]],[1,-1]]
expected: -1
Starter codePython
def second_directional_derivative(h, v):
    # Your code here
    pass

3 test cases · run your code against them in the editor