prompt: What is the theoretical and practical relationship between the open-loop Phase Margin (PM) and the closed-loop damping ratio (zeta) for a standard second-order system? Explain why this approximation holds and where it breaks down.

key_concepts: zeta approx PM / 100 (for PM in degrees <= 60 deg)

key_concepts: Exact formula PM = arctan(2*zeta / sqrt(sqrt(1+4*zeta^4) - 2*zeta^2))

key_concepts: Approximation holds accurately for 0 <= zeta <= 0.6

key_concepts: Breaks down for high phase margins (PM > 70 deg) or systems with non-dominant high-frequency poles/zeros


prompt: Compare the Controllability Matrix rank condition (Kalman test) with the Popov-Belevitch-Hautus (PBH) rank test. When is PBH preferred in engineering practice, and what additional modal information does PBH provide?

key_concepts: Kalman matrix C = [B, AB, ..., A^(n-1)B] can be numerically ill-conditioned for large n due to matrix powers

key_concepts: PBH test checks rank([lambda*I - A, B]) = n for every eigenvalue lambda of A

key_concepts: PBH directly identifies uncontrollable modes (eigenvalues where rank drops)

key_concepts: PBH immediately determines stabilizability (if uncontrollable modes have Re(lambda) < 0)


prompt: Why do Right-Half-Plane (RHP) zeros impose fundamental performance limitations in feedback control systems? Explain using the Poisson Integral formula or Bode sensitivity integral (waterbed effect).

key_concepts: RHP zeros cause initial undershoot in step response

key_concepts: Bode sensitivity integral (waterbed effect): reduction of sensitivity |S(jw)| at low frequencies forces amplification elsewhere

key_concepts: RHP zero at z requires closed-loop bandwidth to be bounded below approximately z/2

key_concepts: Cannot invert RHP zeros without creating unstable closed-loop pole-zero cancelations


prompt: Explain the fundamental difference between Lyapunov's Indirect Method (linearization) and Lyapunov's Direct Method. What are the limitations of indirect linearization regarding asymptotic stability and domain of attraction?

key_concepts: Indirect method: linearizes Jacobian at equilibrium; Re(lambda) < 0 implies local asymptotic stability

key_concepts: Indirect method fails / is inconclusive if any eigenvalue has Re(lambda) = 0 (critical cases)

key_concepts: Indirect method provides no information on domain of attraction (valid only in an infinitesimal neighborhood)

key_concepts: Direct method: constructs positive-definite V(x) with negative semi-definite or negative definite V_dot; valid globally or over an estimated invariant set


prompt: State the Separation Principle for Linear-Quadratic-Gaussian (LQG) control. Under what conditions does it hold, and why does LQG lack the guaranteed robustness margins of deterministic LQR?

key_concepts: Separation principle: optimal controller decomposes into deterministic LQR state feedback K and optimal Kalman state observer L independently

key_concepts: Closed-loop eigenvalues are exactly the union of LQR poles and observer poles

key_concepts: Doyle (1978) showed that LQG has no guaranteed gain or phase margins (can have arbitrarily small gain margin)

key_concepts: Observer loop recovery (LTR) is required to restore LQR robustness


prompt: How does the stability boundary differ between continuous-time LTI systems and discrete-time LTI systems? What conformal mapping connects the continuous s-plane to the discrete z-plane, and what happens to imaginary axis poles under exact discretization?

key_concepts: Continuous stability: Re(s) < 0 (left-half plane)

key_concepts: Discrete stability: |z| < 1 (strictly inside the unit circle)

key_concepts: Imaginary axis s = j*omega maps onto the unit circle |z| = 1 at angle omega * Ts


prompt: What is the Internal Model Principle (Francis and Wonham)? Explain why an integrator is required in the feedback loop to achieve zero steady-state error for a step reference or constant disturbance.

key_concepts: Internal Model Principle: To asymptotically track or reject a class of exogenous signals without steady-state error, the feedback loop must contain a dynamic model of that signal generator

key_concepts: A step reference/disturbance is generated by 1/s; hence the loop must contain a pole at s=0 (integrator)

key_concepts: A sinusoidal reference sin(w*t) requires loop to contain 1/(s^2 + w^2)

key_concepts: Provides structural robustness against plant parameter variations


prompt: What are the guaranteed classical stability margins for continuous-time Linear Quadratic Regulators (LQR) with diagonal R matrix? State both the gain margin and phase margin guarantees.

key_concepts: Guaranteed Gain Margin: GM in [1/2, infinity) (or -6 dB to +infinity dB)

key_concepts: Guaranteed Phase Margin: PM >= 60 degrees (at least +/- 60 deg)

key_concepts: Result stems from Kalman inequality (return difference inequality): ||I + R^(1/2) K (sI-A)^(-1) B R^(-1/2)|| >= 1 for s=jw


prompt: Contrast the Small Gain Theorem with the Passivity Theorem in nonlinear and robust feedback control. When is passivity preferred over small-gain?

key_concepts: Small Gain Theorem: requires norm product ||G1|| * ||G2|| < 1; gain-based, conservative when loop gain is large at low frequencies

key_concepts: Passivity Theorem: requires positive realness / passivity (Re <u, y> >= 0); phase-based, independent of gain magnitude

key_concepts: Passivity is preferred in physical systems (mechanical, electrical, robotics) with energy storage and collocated actuators/sensors where infinite gain margin is achievable


prompt: Explain Bode's Gain-Phase Relationship for stable minimum-phase systems. What does a -20 dB/decade slope in magnitude imply for the phase at that frequency?

key_concepts: Bode's Gain-Phase theorem: phase angle is uniquely determined by the logarithmic derivative of magnitude with respect to log frequency over all frequencies

key_concepts: A constant magnitude slope of -20 dB/decade (-1 log slope) corresponds to approximately -90 degrees of phase shift

key_concepts: A slope of -40 dB/decade corresponds to approximately -180 degrees (stability crossover hazard)

key_concepts: Applies only to minimum-phase systems (no RHP zeros or delays)


prompt: Discretize the continuous plant with A=[[0, 1], [-4, -5]], B=[[0], [2]] under exact Zero-Order Hold (ZOH) at sample time Ts=0.1 s. Report the discrete matrices Ad and Bd.


prompt: Design a continuous-time LQR state feedback controller for system A=[[0, 1], [-2, -3]], B=[[0], [1]] with state weighting Q=[[10, 0], [0, 1]] and control penalty R=[[1]]. Compute the Riccati matrix P, gain K, and closed-loop poles.


prompt: Compute the discrete-time LQR state feedback gain for plant Ad=[[1.0, 0.1], [0.0, 0.95]], Bd=[[0.005], [0.1]] with weights Q=[[5, 0], [0, 1]] and R=[[0.5]]. Report the DARE Riccati matrix P and discrete feedback gain K.


prompt: A single integrator x_dot = u has a state limit x >= -1.0. With barrier h(x) = x - x_min, apply the CBF forward-invariance condition with alpha = 1.5. If the current state is x = -0.7 and nominal control is u_nom = -3.0, compute the filtered safe control input u.


prompt: For the scalar nonlinear affine system x_dot = 0.5*x + 2.0*u, design a dynamic inversion control input u to track setpoint r = 3.0 from state x = 1.0 with tracking convergence gain k = 4.0.


prompt: A cubic interval polynomial has ascending-power coefficient bounds lower_bounds=[2.0, 3.0, 4.0, 1.0] and upper_bounds=[2.5, 3.5, 4.5, 1.2]. Apply Kharitonov's Theorem to test whether the system is robustly Hurwitz stable.


prompt: Given a 3-actuator redundant control effectiveness matrix B=[1.0, 2.0, 3.0], compute the minimum 2-norm control allocation vector u that produces virtual torque tau = 28.0.


prompt: Perform a discrete Kalman filter measurement update for state prediction x_minus=[2.0, 0.0] and covariance P_minus=[[1.0, 0.0], [0.0, 1.0]] with measurement matrix H=[[1.0, 0.0]], measurement noise R=[[0.2]], and observed measurement z=[2.6]. Report the Kalman gain K and updated state x_plus.


prompt: Estimate parameters theta = [a, b]^T for regressor matrix Phi=[[1.0, 2.0], [2.0, 1.0], [3.0, 4.0]] and output Y=[[5.0], [4.0], [11.0]] using ordinary least squares.


prompt: Compute state feedback gain K for system A=[[0, 1], [-2, -3]], B=[[0], [1]] to place closed-loop poles at [-4.0, -5.0].


prompt: A temperature process has static gain K=2.5, time constant tau=10.0 s, and delay L=2.0 s. Tune a PID controller for 0% overshoot setpoint tracking using the Chien-Hrones-Reswick (CHR) method.


prompt: Solve the continuous Lyapunov equation A^T P + P A = -Q for stable matrix A=[[-2, 1], [0, -3]] with identity state weight Q=[[1, 0], [0, 1]].


prompt: Write a clean, runnable Python script using CVXPY to solve a finite-horizon MPC quadratic program for double integrator Ad=[[1.0, 0.1], [0.0, 1.0]], Bd=[[0.0], [0.1]], Q=diag([10, 1]), R=0.1, initial state x0=[2.0, 0.0], horizon N=10, with input constraint |u| <= 1.0. Include assertions verifying solver optimality.

required_packages: cvxpy numpy


prompt: Write a Python script using scipy.signal to compute the step response of G(s) = 25 / (s^2 + 6s + 25). Calculate and assert that the natural frequency omega_n = 5.0 rad/s, damping ratio zeta = 0.6, and peak overshoot Mp% is approximately 9.5%.

required_packages: scipy numpy


prompt: Write a Python script using scipy.signal to compute the Gain Margin, Phase Margin, and crossover frequencies for open-loop transfer function L(s) = 10 / (s*(s + 1)*(s + 2)). Assert that Gain Margin is 6.0 dB and system is stable.


prompt: Write a Python simulation script for a discrete 1D random walk x[k+1] = x[k] + w[k], y[k] = x[k] + v[k] with Q=0.1, R=1.0 over 50 steps. Implement the predict and update steps, and assert that estimation error covariance P converges to a steady-state value.


prompt: Write a Python script implementing feedback linearization for an inverted pendulum on a motor: theta_ddot = 9.81*sin(theta) + u. Choose control u to achieve linear target dynamics theta_ddot + 4*theta_dot + 4*theta = 0. Simulate from theta(0)=0.5 rad and assert asymptotic convergence to 0.


prompt: Write a Python script to convert state space A=[[0, 1], [-2, -3]], B=[[0], [1]], C=[[1, 0]], D=[[0]] into transfer function G(s) using scipy.signal.ss2tf. Assert numerator is [1.0] and denominator is [1.0, 3.0, 2.0].


prompt: Write a clean MATLAB script that defines continuous state-space matrices A=[0 1; -4 -5], B=[0; 2], C=[1 0], D=[0], discretizes them at Ts=0.05 s using c2d(sys, Ts, 'zoh'), extracts Ad and Bd with ssdata, and asserts Ad has size [2, 2].

must_contain_matlab_syntax: c2d ss ssdata assert


prompt: Write a Python function to construct the Routh array for polynomial s^3 + 2s^2 + 3s + K. Test with K=4 (stable) and K=8 (unstable) and assert correct stability determination.


prompt: Write a Python script to design a discrete Luenberger observer for plant Ad=[[0.8, 0.1], [0.0, 0.7]], C=[[1.0, 0.0]] placing observer poles at [0.2, 0.3] using scipy.signal.place_poles. Assert error dynamics eig(Ad - L*C) matches target.


prompt: Write a Python script using CVXPY to solve control allocation for 4 thrusters B=[[1, 1, 1, 1], [1, -1, 1, -1]] with desired torque tau=[10.0, 0.0] and actuator thrust saturation 0 <= u_i <= 4.0. Assert solver finds optimal feasible thrust allocation.


prompt: Discretize the continuous plant with A=[[0, 1], [-2, -3]], B=[[0], [1]] using exact zero-order hold.


prompt: Design an optimal continuous-time LQR controller for plant A=[[0, 1], [-1, -2]], B=[[0], [1]].


prompt: Tune the PID gains Kp, Ki, and Kd for my DC motor.


prompt: Compute state feedback gain K to place closed-loop poles at [-1, -2] for system A=[[1, 0], [0, 2]], B=[[1], [0]].

reason: System is uncontrollable: second state x2 has zero input coupling and unstable pole at +2.


prompt: Design a Luenberger observer with poles at [-5, -6] for system A=[[0, 1], [0, 2]], C=[[0, 0]].

reason: System is completely unobservable (C matrix is all zeros).


prompt: Use the Routh-Hurwitz criterion directly on the discrete-time characteristic polynomial p(z) = z^2 - 1.5z + 0.7 to check stability inside the unit circle.

reason: Routh-Hurwitz tests left-half plane stability (Re(s)<0). For discrete polynomials (unit circle |z|<1), one must either apply the Jury stability test or perform a bilinear transformation z = (1+w)/(1-w) before Routh.


prompt: Compute the nonlinear dynamic inversion input u to track r=1.0 for system x_dot = -x + 0.0*u.

reason: Control effectiveness b = 0; system has zero control authority and cannot be inverted.


prompt: Run a Kalman measurement update with prior error covariance P_minus=[[-1.0, 0.0], [0.0, -2.0]].

reason: Covariance matrix P must be positive semi-definite (eigenvalues >= 0). Negative eigenvalues represent impossible negative variance.


prompt: Solve the MPC quadratic program for my system to regulate state to origin.


prompt: Place all closed-loop poles at s = -100 for a continuous system with 500 ms pure time delay e^(-0.5s).

reason: Time delay introduces infinite dimensional dynamics with negative phase lag; attempting ultra-fast bandwidth (s = -100) on a 500 ms delay violates phase crossover and induces severe instability.


prompt: For an inverted pendulum on a cart with cart mass M=1.0 kg, pendulum mass m=0.1 kg, length l=0.5 m, and g=9.81 m/s^2: linearize the equations of motion around the upright equilibrium (theta=0, x=0), state the continuous matrices (A, B), and formulate the LQR CARE problem.

linearized_model: x = [p, p_dot, theta, theta_dot]^T

eigenvalues: contains one unstable RHP pole at sqrt(g*(M+m)/(M*l)) approx +4.64 rad/s

lqr_formulation: Requires Q >= 0, R > 0 with CARE solve


prompt: Derive the state-space representation for an armature-controlled DC motor with armature resistance R=2.0 ohm, inductance L=0.01 H, torque constant Kt=0.05 N*m/A, back-EMF constant Ke=0.05 V/(rad/s), rotor inertia J=0.001 kg*m^2, and viscous friction b=0.0001 N*m*s/rad. State vector is x = [theta, omega, i_a]^T and input is armature voltage V.

equations: i_a_dot = (1/L)*V - (R/L)*i_a - (Ke/L)*omega

dimension: 3x3 state matrix A, 3x1 input matrix B


prompt: For a quadrotor UAV attitude dynamics in body frame: J * omega_dot + omega x (J * omega) = tau. Under small angles (hover), state the decoupled roll-pitch-yaw equations of motion and design a PD attitude controller tau_phi = Kp*(phi_des - phi) - Kd*p.

decoupled_hover: I_xx * phi_ddot = tau_phi, I_yy * theta_ddot = tau_theta, I_zz * psi_ddot = tau_psi

pd_closed_loop: phi_ddot + (Kd/I_xx)*phi_dot + (Kp/I_xx)*phi = (Kp/I_xx)*phi_des

second_order_tuning: Kp = I_xx * omega_n^2, Kd = 2 * I_xx * zeta * omega_n


prompt: Formulate the 2-DOF state-space model for a quarter-car active suspension with sprung mass m_s, unsprung mass m_u, suspension spring k_s, suspension damper c_s, tire stiffness k_t, and active actuator force u. Define the state vector and write the equations of motion.

states: x = [z_s - z_u, z_s_dot, z_u - z_r, z_u_dot]^T

sprung_eom: m_s * z_s_ddot = -k_s*(z_s - z_u) - c_s*(z_s_dot - z_u_dot) + u

unsprung_eom: m_u * z_u_ddot = k_s*(z_s - z_u) + c_s*(z_s_dot - z_u_dot) - k_t*(z_u - z_r) - u


prompt: A hard disk drive voice coil motor positioning head is modeled as a double integrator G(s) = K_v / s^2 with high-frequency resonant modes. Explain why a Notch Filter is placed in series with the lead-lag/PID compensator in the loop.

resonance_issue: Mechanical structural resonance causes high peak gain and phase drop, destabilizing the high-bandwidth track-following loop

notch_filter_role: N(s) = (s^2 + 2*zeta_z*w_n*s + w_n^2)/(s^2 + 2*zeta_p*w_n*s + w_n^2) introduces narrow deep attenuation at resonant frequency w_n without reducing low-frequency loop gain


prompt: A single-link robot with flexible joint is modeled by motor inertia J_m, link inertia J_l, joint torsional stiffness k, and gear damping b. State why this 4th-order system exhibits non-collocated sensor/actuator dynamics if position is measured at the link tip while torque is applied at the motor.

collocation: Collocated (measuring motor position): interlaced alternating poles and zeros on imaginary axis, always passive and easily stabilized

non_collocated: Measuring link tip: transfer function has only poles and no minimum-phase zeros in the mid-frequency range, leading to 360 deg phase lag and severe stability limits


prompt: For an aircraft short-period longitudinal dynamics: alpha_dot = Z_alpha * alpha + q, q_dot = M_alpha * alpha + M_q * q + M_delta_e * delta_e. Explain the role of Pitch Rate (q) feedback (Pitch Damper) in augmenting short-period damping ratio zeta_sp.

short_period_characteristic: s^2 - (M_q + Z_alpha)*s + (M_q*Z_alpha - M_alpha) = 0

pitch_damper_law: delta_e = -K_q * q

damping_augmentation: Increases the effective M_q derivative (M_q_effective = M_q - M_delta_e * K_q), directly shifting the linear s coefficient and boosting zeta_sp


prompt: A magnetic levitation system m*y_ddot = m*g - k*(i/y)^2 is open-loop unstable with linearization transfer function G(s) = -K_m / (s^2 - a^2). Explain why pure proportional feedback cannot stabilize this system and design a stabilizing Lead Compensator C(s) = K_c * (s + z)/(s + p).

root_locus_failure: Open-loop poles at s = +a and s = -a. Under pure proportional control, closed-loop poles move along imaginary axis from +/- a towards infinity, remaining on stability boundary with 0 damping

lead_compensator_action: Placing zero z < a and pole p > a pulls root locus branches into the left-half plane, providing phase lead at crossover frequency and ensuring asymptotic stability