All problems
Lyapunov Quadratic Check
Problem
For V(x) = x^T P x with P = [[p, q], [q, r]] and the linear system x' = A x with A = [[a, b], [c, d]], the derivative along trajectories is V-dot = x^T Q x with Q = P*A + A^T*P.
Return [q11, q12, q22, is_negative_definite], where Q = [[q11, q12], [q12, q22]]. A 2x2 symmetric matrix is negative definite when q11 < 0 and q11*q22 - q12^2 > 0.
Hint
A negative definite Q proves asymptotic stability of the origin.
Test cases
case 1
in: [0,1,-2,-3,1,0,1]
expected: [0,-1,-6,false]
case 2
in: [0,1,-2,-3,3,1,1]
expected: [-4,-2,-4,true]
case 3
in: [1,0,0,1,1,0,1]
expected: [2,0,2,false]
case 4
in: [-1,0,0,-2,1,0,1]
expected: [-2,0,-4,true]
case 5
in: [0,1,1,0,1,0,1]
expected: [0,2,0,false]
Starter codePython
def lyapunov_check(a, b, c, d, p, q, r):
# Return [q11, q12, q22, flag]
# Your code here
pass5 test cases · run your code against them in the editor