All problems
Gradient Flow Euler Step
Problem
Take one explicit Euler step of the gradient flow dx/dt = -grad.
Return x - dt * grad, where dt is the step size.
Hint
Euler integration follows the negative gradient direction for one step.
Test cases
case 1
in: [1,2,0.1]
expected: 0.8
case 2
in: [0,1,0.5]
expected: -0.5
case 3
in: [2,-1,0.25]
expected: 2.25
case 4
in: [3,0,0.1]
expected: 3
Starter codePython
def euler_step(x, grad, dt):
# Your code here
pass4 test cases · run your code against them in the editor