Skip to content
DeepForgeby svx
All problems
EasyCalculusca-111

Gradient Flow Energy Step

Problem

Take one gradient-flow (steepest descent) step on the energy V(x) = 0.5*a*x^2 + 0.25*b*x^4 and return the energy at the new point.

The update is x_new = x - lr * V'(x) with V'(x) = a*x + b*x^3, so the result is V(x_new).

Hint

Gradient flow moves down the energy; a small step should reduce V.

Test cases

case 1
in: [1,0.1,1,0]
expected: 0.405
case 2
in: [2,0.25,1,1]
expected: 0.140625
case 3
in: [0,0.5,1,1]
expected: 0
case 4
in: [1,0,1,1]
expected: 0.75
Starter codePython
def gradient_flow_energy(x, lr, a, b):
    # Your code here
    pass

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