All problems
Euler Stability Condition
Problem
Forward Euler applied to y' = lam*y multiplies the value by the amplification factor 1 + h*lam at every step.
The method is stable when |1 + h*lam| <= 1. Given lam and the step size h, return [factor, stable] where stable is a boolean.
Hint
For negative lam the stability limit is h <= 2 / |lam|.
Test cases
case 1
in: [-10,0.1]
expected: [0,true]
case 2
in: [-10,0.25]
expected: [-1.5,false]
case 3
in: [0,5]
expected: [1,true]
case 4
in: [-2,1]
expected: [-1,true]
Starter codePython
def euler_stability(lam, h):
# Return [factor, stable]
# Your code here
pass4 test cases · run your code against them in the editor