All problems
Max Directional Derivative
Problem
The maximum possible directional derivative of a scalar field at a point equals the norm of its gradient, attained in the direction of the gradient.
Given the gradient vector grad, return ||grad||.
Hint
This is the steepest ascent rate; take the Euclidean length of the gradient.
Test cases
case 1
in: [[3,4]]
expected: 5
case 2
in: [[0,0]]
expected: 0
case 3
in: [[1,2,2]]
expected: 3
case 4
in: [[-5,12]]
expected: 13
case 5
in: [[1]]
expected: 1
Starter codePython
def max_directional_derivative(grad):
# Your code here
pass5 test cases · run your code against them in the editor