All problems
Heavy Ball Stability Check
Problem
Check the stability of heavy-ball momentum on a quadratic with curvature L.
The iteration converges when lr > 0, 0 <= mu < 1, and lr * L < 2 * (1 + mu) all hold. Return True only when every condition is satisfied.
Hint
Higher momentum buys a slightly larger stable step size.
Test cases
case 1
in: [0.1,1,0.9]
expected: true
case 2
in: [0.5,1,0]
expected: true
case 3
in: [2.5,1,0.5]
expected: true
case 4
in: [1,1,1]
expected: false
case 5
in: [-0.1,1,0.5]
expected: false
Starter codePython
def heavy_ball_stable(lr, L, mu):
# Your code here
pass5 test cases · run your code against them in the editor