Skip to content
DeepForgeby svx
All problems
MediumCalculusca-265

Gradient Flow on a Double-Well Potential

Problem

Gradient flow on the double-well potential V(x) = (x^2 - 1)^2 follows x_new = x - lr * V'(x) with V'(x) = 4*x*(x^2 - 1).

Given the current point x and the learning rate lr, take one step and return [x_new, V(x_new)]. The potential has minima at x = -1 and x = 1.

Hint

At the origin the gradient is zero, so the flow stays on the barrier top.

Test cases

case 1
in: [2,0.1]
expected: [-0.4,0.7056]
case 2
in: [0,0.5]
expected: [0,1]
case 3
in: [1,0.1]
expected: [1,0]
case 4
in: [0.5,0.2]
expected: [0.8,0.1296]
Starter codePython
def double_well_flow_step(x, lr):
    # Return [x_new, V(x_new)]
    # Your code here
    pass

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