Skip to content
DeepForgeby svx
All problems
EasyCalculusca-355

Descent Direction Check

Problem

A step direction d is a descent direction at a point with gradient g when the directional derivative g dot d is negative.

Given the gradient and the step, return [g dot d, boolean] where the boolean is true when the dot product is strictly negative.

Hint

Compute the dot product; a strict negative value signals descent.

Test cases

case 1
in: [[1,1],[-1,-1]]
expected: [-2,true]
case 2
in: [[1,0],[1,0]]
expected: [1,false]
case 3
in: [[2,-3],[-1,-1]]
expected: [1,false]
Starter codePython
def descent_direction_check(grad, step):
    # Your code here
    pass

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