Skip to content
DeepForgeby svx
All problems
MediumOptimizationop-148

Momentum Optimal Beta

Problem

Compute the optimal momentum coefficient for a quadratically convergent scheme.

With kappa = L / mu and r = sqrt(kappa), return (r - 1) / (r + 1). Return 0.0 when mu is not positive.

Hint

The optimal momentum depends only on the square root of the condition number.

Test cases

case 1
in: [1,4]
expected: 0.3333333333333333
case 2
in: [0.5,2]
expected: 0.3333333333333333
case 3
in: [1,1]
expected: 0
case 4
in: [0.1,10]
expected: 0.8181818181818182
Starter codePython
def momentum_optimal_beta(mu, L):
    # Your code here
    pass

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