Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Lyapunov Stability Analysis
00:00
5 left

Lyapunov Stability Analysis

HardPython

Problem

Write a Lyapunov stability analysis for a first order differential equation.

Implement a numerical certificate for the scalar system x' = f(x), where f is represented by polynomial coefficients in ascending order. Use V(x) = 0.5 * (x - x_eq)^2 and evaluate V_dot = (x - x_eq) * f(x) at evenly spaced points on both sides of the equilibrium.

Return "asymptotically_stable" if every sampled derivative is less than -tolerance, "stable" if all are at most tolerance but at least one is nonnegative within tolerance, and "unstable" if any exceeds the tolerance.

Function signature: def classify_equilibrium(coefficients, x_eq, radius, samples, tolerance):

Input values are numeric; output is one of the three specified strings.

Constraints

  • 1 <= len(coefficients) <= 100
  • -10^6 <= coefficients[i] <= 10^6
  • radius > 0
  • 1 <= samples <= 100000
  • 0 <= tolerance < 1
  • The supplied x_eq is an equilibrium of the polynomial, subject to the requested tolerance

Function Signature

def classify_equilibrium(coefficients, x_eq, radius, samples, tolerance):
Interviewer

Your question is Lyapunov Stability Analysis. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.