All problems
Phase Portrait Stability
Problem
For a 2D linear system x' = A*x with trace T and determinant D, the origin is classified by these invariants.
Return "saddle" when D < 0, "stable" when D > 0 and T < 0, "unstable" when D > 0 and T > 0, and "center" when D > 0 and T == 0. When D == 0, return "degenerate".
Hint
The eigenvalues are the roots of lambda^2 - T*lambda + D, and their signs decide stability.
Test cases
case 1
in: [-2,1]
expected: "stable"
case 2
in: [2,1]
expected: "unstable"
case 3
in: [0,4]
expected: "center"
case 4
in: [0,-1]
expected: "saddle"
case 5
in: [3,0]
expected: "degenerate"
Starter codePython
def phase_stability(trace, det):
# Your code here
pass5 test cases · run your code against them in the editor