Control Systems Modeling: How Linear Algebra Represents Feedback, Inputs, and Stabilization

Last Updated June 29, 2026

Control systems modeling explains how linear algebra represents systems that are not only observed, but acted upon. A state vector describes the system, a system matrix describes internal dynamics, an input matrix describes how interventions enter, an output matrix describes what can be measured, and feedback connects observed or estimated state back into decisions. Control modeling turns matrices into a language for stabilization, response, regulation, tracking, observability, controllability, uncertainty, and responsible intervention.

This article closes Part IV of the Linear Algebra for Systems Modeling series by connecting eigenstructure, matrix differential equations, state-space models, feedback, inputs, outputs, controllability, observability, stability, pole placement, optimal control, simulation, uncertainty, and governance. It prepares the transition from dynamical behavior to network structure, where matrices will organize connectivity, flows, influence, and vulnerability.

The central modeling question is not only “Can the system be controlled?” It is “What can be controlled, through which inputs, from which observations, under what assumptions, with what risks, and according to whose definition of acceptable system behavior?”

Vintage engineering workspace with feedback-loop diagrams, response curves, phase portraits, network structures, mechanical sketches, books, and drafting tools.
Control systems modeling shown through feedback structures, dynamic response, stability patterns, system interconnections, and engineered behavior over time.

Control systems modeling begins when a system is not merely described but influenced. A dam releases water. A power grid adjusts generation. A vehicle changes steering. A public-health program changes intervention intensity. An economic regulator adjusts policy levers. A building-management system changes heating and cooling. A robot changes motor commands. A platform changes ranking signals. In each case, the model contains not only internal dynamics but also inputs, outputs, and feedback.

Linear algebra gives control modeling its basic structure. The state matrix describes how the system evolves internally. The input matrix describes how actions enter the system. The output matrix describes what is measured. Feedback matrices describe how control decisions depend on state or output. Eigenvalues describe stability and response. Rank tests diagnose controllability and observability. Numerical simulation tests whether theoretical control claims survive finite precision, constraints, uncertainty, and domain assumptions.

Why Control Systems Modeling Matters

Control systems modeling matters because many systems are governed, regulated, managed, stabilized, optimized, or steered. A purely descriptive model asks how a system behaves. A control model asks how actions influence behavior, how feedback changes dynamics, and whether the system can be driven toward a desired state without creating unacceptable instability, cost, risk, or unintended harm.

Linear control models are especially important because they organize system dynamics, control inputs, outputs, and feedback into matrix form. This makes intervention mathematically analyzable. It also makes the ethical and institutional stakes clearer: control is not only prediction. It is structured action.

Control question Linear algebra object Systems interpretation
What is the internal system state? State vector \(\mathbf{x}\) Variables needed to describe the system.
How does the system evolve? State matrix \(A\) Internal dynamics and coupling.
How do actions enter? Input matrix \(B\) Channels through which interventions affect state.
What can be measured? Output matrix \(C\) Observed quantities or sensor readings.
How does feedback act? Feedback matrix \(K\) Control rule based on state or estimates.
Can the system be influenced? Controllability matrix. Whether inputs can move the state through relevant directions.
Can the state be inferred? Observability matrix. Whether outputs contain enough information about internal state.

Control systems modeling is where linear algebra becomes a theory of intervention.

Back to top ↑

State, Input, and Output

A control model distinguishes among state, input, and output. The state describes what the system is internally. The input describes what can be done to the system. The output describes what can be measured from the system.

\[
\mathbf{x}(t)=
\begin{bmatrix}
x_1(t)\\
x_2(t)\\
\vdots\\
x_n(t)
\end{bmatrix},
\qquad
\mathbf{u}(t)=
\begin{bmatrix}
u_1(t)\\
u_2(t)\\
\vdots\\
u_m(t)
\end{bmatrix},
\qquad
\mathbf{y}(t)=
\begin{bmatrix}
y_1(t)\\
y_2(t)\\
\vdots\\
y_p(t)
\end{bmatrix}
\]

Interpretation: The state vector describes internal system variables, the input vector describes actions or external signals, and the output vector describes measured quantities.

Object Formal role Systems modeling meaning
State \(\mathbf{x}\) Internal coordinates. Condition, storage, memory, position, stress, inventory, population, or other system variables.
Input \(\mathbf{u}\) Action or forcing vector. Control signal, intervention, shock, policy lever, actuator command, or resource allocation.
Output \(\mathbf{y}\) Measured vector. Sensor reading, report, indicator, observable variable, performance metric, or partial view.
State dimension \(n\) Number of internal variables. How much internal structure the model represents.
Input dimension \(m\) Number of independent action channels. How many levers are available.
Output dimension \(p\) Number of measured quantities. How much of the system can be observed.

This distinction matters because control problems often fail when the available inputs do not influence the relevant states, or when the available outputs do not reveal the internal conditions needed for safe feedback.

Back to top ↑

State-Space Representation

The standard continuous-time linear state-space model is:

\[
\frac{d\mathbf{x}}{dt}=A\mathbf{x}(t)+B\mathbf{u}(t)
\]

Interpretation: The state changes according to internal dynamics plus control input.

The output equation is:

\[
\mathbf{y}(t)=C\mathbf{x}(t)+D\mathbf{u}(t)
\]

Interpretation: The observed output depends on internal state and possibly direct input feedthrough.

The matrices \(A\), \(B\), \(C\), and \(D\) define the structure of the control model.

Matrix Formal role Systems interpretation
\(A\) State matrix. Internal dynamics and coupling among states.
\(B\) Input matrix. How control inputs, interventions, or shocks enter the state.
\(C\) Output matrix. How internal state becomes measured output.
\(D\) Feedthrough matrix. Immediate input-to-output effect, when present.
\((A,B,C,D)\) State-space realization. Complete linear control representation.

State-space representation is more than notation. It separates internal behavior, intervention channels, and measurement structure in a way that can be tested with linear algebra.

Back to top ↑

Continuous-Time Control Models

Continuous-time control models describe systems whose state evolves according to rates of change. The input can vary continuously over time:

\[
\dot{\mathbf{x}}(t)=A\mathbf{x}(t)+B\mathbf{u}(t)
\]

Interpretation: The dot notation \(\dot{\mathbf{x}}\) represents the derivative of the state with respect to time.

The natural response is governed by the matrix exponential \(e^{At}\). The forced response accumulates input effects over time:

\[
\mathbf{x}(t)=e^{At}\mathbf{x}(0)+\int_0^t e^{A(t-\tau)}B\mathbf{u}(\tau)\,d\tau
\]

Interpretation: The state combines unforced evolution from the initial condition with accumulated input response.

Continuous-time feature Mathematical object Control interpretation
Natural dynamics \(e^{At}\mathbf{x}(0)\) What the system does without further input.
Input response Integral involving \(B\mathbf{u}\) How control actions accumulate over time.
Stability Real parts of eigenvalues of \(A\) Whether unforced modes decay or amplify.
Control authority Structure of \(B\) Which states can be affected by inputs.
Measurement Structure of \(C\) Which internal states are visible through outputs.

Continuous-time control is central in engineering, physical systems, energy systems, robotics, process control, and many scientific models.

Back to top ↑

Discrete-Time Control Models

Discrete-time control models update the state step by step:

\[
\mathbf{x}_{t+1}=A\mathbf{x}_t+B\mathbf{u}_t
\]

Interpretation: The next state depends on the current state and the current input.

The output equation is:

\[
\mathbf{y}_t=C\mathbf{x}_t+D\mathbf{u}_t
\]

Interpretation: The observed output at step \(t\) depends on the current state and possibly the current input.

Discrete-time control is common in digital systems, sampled-data control, simulation, data-driven modeling, algorithmic decision systems, inventory systems, resource allocation, and policy models updated at fixed intervals.

Feature Continuous time Discrete time
State equation \(\dot{x}=Ax+Bu\) \(x_{t+1}=Ax_t+Bu_t\)
Evolution operator \(e^{At}\) \(A^t\)
Stability rule Eigenvalue real parts negative. Eigenvalue magnitudes less than one.
Input timing Continuous signal. Stepwise or sampled input.
Common applications Physical, engineering, process, and continuous dynamics. Digital, sampled, algorithmic, and period-based dynamics.

Confusing continuous-time and discrete-time control rules can produce serious modeling errors. The same symbol \(A\) has different stability meaning in each time model.

Back to top ↑

Feedback and Closed-Loop Dynamics

Feedback occurs when the control input depends on the state or output. A common state-feedback rule is:

\[
\mathbf{u}(t)=-K\mathbf{x}(t)
\]

Interpretation: The controller uses the current state to choose an input that pushes against undesirable behavior.

Substituting into the continuous-time state equation gives:

\[
\dot{\mathbf{x}}=(A-BK)\mathbf{x}
\]

Interpretation: Feedback changes the effective dynamics from \(A\) to the closed-loop matrix \(A-BK\).

For discrete time, the same feedback form produces:

\[
\mathbf{x}_{t+1}=(A-BK)\mathbf{x}_t
\]

Interpretation: The feedback matrix changes the stepwise update matrix.

System form Matrix Interpretation
Open-loop continuous time \(A\) Natural dynamics without feedback.
Closed-loop continuous time \(A-BK\) Dynamics after state feedback.
Open-loop discrete time \(A\) Natural stepwise update.
Closed-loop discrete time \(A-BK\) Stepwise update after feedback.
Feedback gain \(K\) Rule mapping state to control action.

Feedback is powerful because it changes system dynamics. It is risky for the same reason. A poorly designed controller can destabilize, overcorrect, oscillate, saturate actuators, amplify noise, or optimize the wrong target.

Back to top ↑

Eigenvalues, Poles, and Stability

In state-space control, eigenvalues of the relevant system matrix are often called poles. Open-loop poles come from \(A\). Closed-loop poles come from \(A-BK\) under state feedback.

\[
\lambda(A)
\quad \text{and} \quad
\lambda(A-BK)
\]

Interpretation: Feedback changes the eigenvalues that govern system response.

For continuous time, stable poles should lie in the left half-plane. For discrete time, stable poles should lie inside the unit circle.

Time model Stable pole condition Response interpretation
Continuous time \(\operatorname{Re}(\lambda_i)<0\) Modes decay exponentially.
Discrete time \(|\lambda_i|<1\) Modes shrink under repeated updates.
Near stability boundary Real part near \(0\) or magnitude near \(1\) Slow decay, long memory, or fragile stability.
Complex poles Nonzero imaginary part. Oscillation or cyclic response.
Unstable pole Right half-plane or outside unit circle. Some mode amplifies.

Control design often seeks to move closed-loop poles into desirable regions. But “desirable” depends on response speed, overshoot, energy cost, actuator limits, safety margins, and domain consequences.

Back to top ↑

Controllability

Controllability asks whether available inputs can move the state through the relevant directions of state space. For a continuous-time or discrete-time linear system with state matrix \(A\) and input matrix \(B\), the controllability matrix is:

\[
\mathcal{C}=
\begin{bmatrix}
B & AB & A^2B & \cdots & A^{n-1}B
\end{bmatrix}
\]

Interpretation: The controllability matrix collects directions produced by applying the system dynamics to the input directions.

The system is controllable when this matrix has full row rank:

\[
\operatorname{rank}(\mathcal{C})=n
\]

Interpretation: Full rank means the inputs can influence all state-space directions in the linear model.

Controllability result Mathematical meaning Systems interpretation
Full rank Input directions span the state space through dynamics. The model says all state directions can be influenced.
Rank deficient Some state directions cannot be reached. Some modes are uncontrollable with available inputs.
Nearly rank deficient Directions are technically reachable but ill-conditioned. Control may require excessive effort or be fragile.
Unstable uncontrollable mode Bad mode cannot be moved by input. Stabilization may be impossible under the model.
Domain mismatch Mathematical control does not match real authority. Inputs may not be physically, politically, ethically, or institutionally available.

Controllability is a rank condition, but its interpretation depends on actuator limits, feasible actions, cost, authority, and the reality of the modeled input channels.

Back to top ↑

Observability

Observability asks whether the internal state can be inferred from outputs over time. For state matrix \(A\) and output matrix \(C\), the observability matrix is:

\[
\mathcal{O}=
\begin{bmatrix}
C\\
CA\\
CA^2\\
\vdots\\
CA^{n-1}
\end{bmatrix}
\]

Interpretation: The observability matrix collects how state directions appear in outputs over repeated dynamics.

The system is observable when:

\[
\operatorname{rank}(\mathcal{O})=n
\]

Interpretation: Full rank means outputs contain enough dynamic information to reconstruct the internal state in the linear model.

Observability result Mathematical meaning Systems interpretation
Full rank State directions are visible through outputs over time. Internal state can be inferred from measurements under the model.
Rank deficient Some state directions are hidden. Important internal conditions may be invisible.
Nearly rank deficient State inference is ill-conditioned. Small measurement errors can cause large state-estimation errors.
Unobserved unstable mode Dangerous mode is hidden from outputs. Feedback may fail because the system cannot detect the problem.
Measurement mismatch Output equation fails domain reality. Indicators may be biased, delayed, noisy, or strategically manipulated.

Observability is not merely a sensor question. It is a question about what the system reveals, what remains hidden, and whether feedback decisions are based on reliable information.

Back to top ↑

Stabilization and Pole Placement

Stabilization asks whether feedback can make the closed-loop system stable. Pole placement asks whether a feedback matrix \(K\) can place the eigenvalues of \(A-BK\) at desired locations.

\[
\lambda(A-BK)=\{\mu_1,\mu_2,\ldots,\mu_n\}
\]

Interpretation: Pole placement chooses feedback so the closed-loop matrix has selected eigenvalues.

In theory, controllable systems permit broad pole placement. In practice, actuator limits, noise, delay, uncertainty, model error, and cost constrain what can be safely achieved.

StabilizationMove unstable poles to stable region.Requires controllability of unstable modes.

Design objective Mathematical signal Practical caution
Faster response Move poles farther into stable region. May require high input effort or cause actuator saturation.
Less oscillation Adjust complex poles and damping. May slow response or reduce performance.
Robustness Maintain stability under perturbations. Nominal pole placement may be fragile.
Safe intervention Respect constraints and domain limits. Mathematical stabilization is not automatically acceptable control.

Control design is not simply moving eigenvalues. It is shaping system response under real constraints.

Back to top ↑

Optimal Control

Optimal control introduces an objective function. Instead of merely stabilizing the system, the modeler asks which control input balances performance, effort, risk, and constraints. A common linear-quadratic form minimizes state deviation and input effort:

\[
J=\int_0^\infty \left(\mathbf{x}(t)^TQ\mathbf{x}(t)+\mathbf{u}(t)^TR\mathbf{u}(t)\right)\,dt
\]

Interpretation: The cost function penalizes undesirable state behavior and costly control effort.

Here, \(Q\) weights state deviations and \(R\) weights input effort. The design is not neutral. The weights encode priorities.

Optimal-control object Role Governance question
\(Q\) State penalty matrix. Which states are treated as costly or dangerous?
\(R\) Input penalty matrix. How expensive or constrained are interventions?
\(J\) Objective function. What definition of optimal behavior is being used?
Optimal feedback Control law derived from objective. Does the objective match domain values and constraints?
Tradeoff Performance versus effort. Who bears the cost of control and who receives the benefit?

Optimal control makes value choices explicit through mathematical weights. Responsible modeling requires explaining those choices, not hiding them inside \(Q\), \(R\), or a performance index.

Back to top ↑

Constraints, Saturation, and Real Actuators

Linear control models often assume inputs can take whatever values the feedback law demands. Real systems do not behave this way. Actuators saturate. Budgets are limited. Policies face legal constraints. Physical systems have bounds. Infrastructure actions require time. Social systems resist abrupt intervention. Digital systems may create feedback loops or unintended incentives.

\[
\mathbf{u}_{\min}\leq \mathbf{u}(t)\leq \mathbf{u}_{\max}
\]

Interpretation: Real control inputs are often bounded by actuator, resource, legal, physical, or institutional limits.

Constraint Control implication Modeling warning
Actuator saturation Controller asks for more input than available. Closed-loop stability analysis may no longer apply.
State constraints States must remain within feasible bounds. Linear dynamics can produce impossible values.
Rate limits Inputs cannot change instantly. Fast feedback may be infeasible.
Delay Inputs affect state after a lag. Delay can destabilize feedback.
Institutional constraints Not all interventions are lawful, ethical, or available. Mathematical control authority may exceed real authority.

Control models become more credible when they acknowledge constraints rather than assuming unlimited intervention capacity.

Back to top ↑

Uncertainty, Robustness, and Sensitivity

Control systems depend on matrices that may be estimated, simplified, uncertain, or changing. Robustness asks whether the system remains stable and acceptable when the model is wrong within plausible limits.

\[
A_{\text{true}}=A+\Delta A,
\qquad
B_{\text{true}}=B+\Delta B
\]

Interpretation: The true system may differ from the modeled system because of uncertainty, estimation error, or structural change.

Uncertainty source Control risk Diagnostic response
Parameter uncertainty Incorrect matrix entries. Run perturbation and sensitivity tests.
Unmodeled dynamics Important variables excluded. Review residuals, domain structure, and hidden states.
Measurement noise Feedback responds to noisy output. Use filtering, uncertainty modeling, and noise sensitivity checks.
Delay Control acts on stale information. Analyze delayed dynamics and response margins.
Regime change System matrix changes over time. Use scenario analysis and adaptive review.
Strategic response Agents react to the controller. Review incentives, gaming, feedback loops, and institutional context.

A controller that works only for the nominal matrix may fail in the real system. Robustness is therefore a modeling requirement, not an optional refinement.

Back to top ↑

Simulation and Validation

Simulation helps test whether control behavior matches expectations over finite horizons. A modeler can compare open-loop and closed-loop trajectories, test different initial conditions, apply disturbances, enforce input limits, inspect state constraints, and measure response speed, overshoot, settling, effort, and robustness.

Simulation diagnostic Purpose Warning
Open-loop trajectory Shows natural system behavior. May be unstable, slow, or oscillatory.
Closed-loop trajectory Shows behavior under feedback. Stability depends on modeled dynamics and controller assumptions.
Control effort Tracks input magnitude over time. High effort may be infeasible or unsafe.
Constraint checks Verifies state and input feasibility. Linear analysis can miss saturation and bounds.
Disturbance tests Measures response to shocks. Nominal stability may not imply robust recovery.
Scenario comparisons Tests alternative matrices and policies. Control claims should survive plausible uncertainty.

Validation should compare the model’s controlled behavior with physical evidence, observed system response, engineering constraints, institutional limits, or domain-specific performance criteria. Simulation is not validation by itself. It is a structured way to test claims.

Back to top ↑

Control Systems in Systems Modeling

Control systems modeling appears across engineering, infrastructure, ecology, economics, energy, public health, climate adaptation, robotics, operations, digital platforms, and policy systems. In each case, control introduces a new responsibility: the model is not merely describing what may happen, but supporting action that changes what happens.

Domain Control modeling use Interpretive caution
Engineering Stabilization, tracking, regulation, and response shaping. Actuator limits, delays, noise, and safety margins matter.
Infrastructure Traffic control, grid balancing, water systems, maintenance response. Physical constraints and cascading failures can dominate.
Ecology Adaptive management, intervention, harvest, restoration, or containment. Nonlinear thresholds and irreversibility may make simple control misleading.
Economics Policy levers, stabilization, investment response, macro adjustment. Agents adapt, expectations shift, and institutions change the dynamics.
Public health Intervention intensity, resource allocation, treatment response. Human behavior, ethics, equity, and uncertainty shape outcomes.
Digital systems Ranking, recommendation, moderation, attention steering. Feedback loops, incentives, manipulation, and legitimacy concerns are central.

Control models are strongest when the system, inputs, outputs, objectives, constraints, and accountability structure are made explicit.

Back to top ↑

Mathematical Deepening

This section adds a more formal layer. Control systems modeling connects state-space representation, matrix differential equations, discrete-time dynamics, eigenvalues, poles, feedback, closed-loop matrices, controllability, observability, pole placement, stabilization, optimal control, Riccati equations, robustness, state estimation, Kalman filtering, constraints, numerical simulation, and systems governance.

State-Space Review

State Matrix

The matrix \(A\) describes internal dynamics and coupling among state variables.

Input Matrix

The matrix \(B\) describes how control actions enter the state equation.

Output Matrix

The matrix \(C\) describes how internal state becomes measurable output.

Feedthrough Matrix

The matrix \(D\) describes direct input-to-output effects when present.

Feedback Review

Open Loop

The system evolves without using state or output to adjust input.

Closed Loop

Feedback changes the effective dynamics of the system.

Gain Matrix

The matrix \(K\) maps state estimates or measurements into control actions.

Closed-Loop Poles

The eigenvalues of \(A-BK\) determine controlled modal behavior.

Rank Diagnostics

Controllability

The controllability matrix tests whether inputs can influence all state directions.

Observability

The observability matrix tests whether outputs reveal enough information about state.

Conditioning

Nearly rank-deficient matrices can make control or estimation fragile.

Unstable Hidden Modes

Uncontrollable or unobservable unstable modes are serious modeling warnings.

Design Review

Pole Placement

Feedback can shape closed-loop eigenvalues when the system is controllable.

Optimal Control

Objective functions balance state performance and input effort.

Robustness

Control should remain acceptable under plausible model uncertainty.

Constraints

Inputs, states, rates, delays, and institutional authority impose real limits.

Governance Questions

Who Controls?

The model should clarify who has authority to choose inputs and define objectives.

What Is Optimized?

Performance criteria encode priorities, tradeoffs, costs, and values.

What Is Observed?

Feedback quality depends on reliable, legitimate, and meaningful measurements.

What Could Go Wrong?

Control models should examine instability, saturation, gaming, inequity, and unintended consequences.

Back to top ↑

Examples from Systems Modeling

Control systems modeling appears wherever interventions are designed to shape system behavior over time.

Power Grid Control

State-space models can represent frequency, load, generation, storage, and control inputs used to maintain stable electrical service.

Water and Infrastructure Systems

Reservoir, pressure, pump, and flow states can be regulated through feedback policies that balance service, risk, and constraints.

Transportation Networks

Signal timing, routing interventions, and congestion feedback can be modeled as controlled state transitions over time.

Ecological Management

Intervention models can examine harvesting, restoration, containment, or resource allocation under uncertainty and nonlinear thresholds.

Public Health Response

Control inputs may represent vaccination, testing, treatment, communication, or resource allocation affecting disease-state dynamics.

Digital Platform Feedback

Ranking, recommendation, moderation, and exposure systems can steer behavior, creating feedback loops that require governance review.

Across these examples, control systems modeling should keep the system, inputs, measurements, constraints, objectives, uncertainty, and accountability structure visible.

Back to top ↑

Computation and Reproducible Workflows

Computational workflows for control systems modeling should document the state variables, input variables, output variables, time model, state matrix, input matrix, output matrix, feedback gain, open-loop eigenvalues, closed-loop eigenvalues, controllability rank, observability rank, condition numbers, trajectory simulations, input effort, constraint checks, perturbation sensitivity, robustness tests, and governance warnings.

The companion repository treats control systems as auditable intervention models. Python, R, Julia, SQL, Haskell, C, C++, Fortran, Rust, Go, notebooks, schemas, generated outputs, Canvas artifacts, advanced reports, and calculators each support a different layer of reproducible control analysis.

For this article, the computational examples focus on state-space matrices, open-loop and closed-loop stability, controllability, observability, feedback gains, trajectory simulation, and intervention governance records.

Back to top ↑

Python Workflow: Control Systems Audit

The Python workflow below audits a two-state continuous-time control model. It computes open-loop and closed-loop eigenvalues, controllability rank, observability rank, and simple Euler trajectories for open-loop and feedback-controlled behavior.

from __future__ import annotations

from dataclasses import asdict, dataclass
from pathlib import Path
import csv
import json
import math


Matrix = list[list[float]]
Vector = list[float]


@dataclass(frozen=True)
class ControlSystemsAudit:
    system_name: str
    state_names: str
    input_names: str
    output_names: str
    time_model: str
    state_matrix_A: str
    input_matrix_B: str
    output_matrix_C: str
    feedback_matrix_K: str
    open_loop_eigenvalues: str
    closed_loop_eigenvalues: str
    open_loop_max_real_part: float
    closed_loop_max_real_part: float
    controllability_rank: int
    observability_rank: int
    open_loop_final_state: str
    closed_loop_final_state: str
    max_control_effort: float
    control_warning: str
    interpretation_warning: str


def matrix_to_string(A: Matrix) -> str:
    return ";".join(",".join(f"{value:.6f}" for value in row) for row in A)


def vector_to_string(x: Vector) -> str:
    return ",".join(f"{value:.6f}" for value in x)


def matvec(A: Matrix, x: Vector) -> Vector:
    return [sum(A[i][j] * x[j] for j in range(len(x))) for i in range(len(A))]


def matmul(A: Matrix, B: Matrix) -> Matrix:
    return [
        [sum(A[i][k] * B[k][j] for k in range(len(B))) for j in range(len(B[0]))]
        for i in range(len(A))
    ]


def subtract(A: Matrix, B: Matrix) -> Matrix:
    return [
        [A[i][j] - B[i][j] for j in range(len(A[0]))]
        for i in range(len(A))
    ]


def determinant_2x2(A: Matrix) -> float:
    return A[0][0] * A[1][1] - A[0][1] * A[1][0]


def rank_2x2(A: Matrix, tolerance: float = 1e-10) -> int:
    if abs(determinant_2x2(A)) > tolerance:
        return 2
    if any(abs(value) > tolerance for row in A for value in row):
        return 1
    return 0


def eigenvalues_2x2_real(A: Matrix) -> tuple[float, float]:
    trace = A[0][0] + A[1][1]
    determinant = determinant_2x2(A)
    discriminant = trace * trace - 4.0 * determinant
    if discriminant < 0:
        raise ValueError("This teaching audit handles real eigenvalues only.")
    root = math.sqrt(discriminant)
    return ((trace + root) / 2.0, (trace - root) / 2.0)


def control_input(K: Matrix, x: Vector) -> Vector:
    raw = matvec(K, x)
    return [-value for value in raw]


def euler_open_loop(A: Matrix, x0: Vector, horizon: float, dt: float) -> Vector:
    x = x0[:]
    for _ in range(int(round(horizon / dt))):
        dx = matvec(A, x)
        x = [x[i] + dt * dx[i] for i in range(len(x))]
    return x


def euler_closed_loop(A: Matrix, B: Matrix, K: Matrix, x0: Vector, horizon: float, dt: float) -> tuple[Vector, float]:
    x = x0[:]
    max_effort = 0.0
    for _ in range(int(round(horizon / dt))):
        u = control_input(K, x)
        max_effort = max(max_effort, max(abs(value) for value in u))
        Ax = matvec(A, x)
        Bu = matvec(B, u)
        dx = [Ax[i] + Bu[i] for i in range(len(x))]
        x = [x[i] + dt * dx[i] for i in range(len(x))]
    return x, max_effort


def build_audit() -> ControlSystemsAudit:
    A = [
        [0.10, 1.00],
        [0.00, 0.20],
    ]
    B = [
        [0.00],
        [1.00],
    ]
    C = [
        [1.00, 0.00],
    ]
    K = [
        [0.50, 1.40],
    ]

    BK = matmul(B, K)
    A_closed = subtract(A, BK)

    open_eigs = eigenvalues_2x2_real(A)
    closed_eigs = eigenvalues_2x2_real(A_closed)

    AB = matmul(A, B)
    controllability = [
        [B[0][0], AB[0][0]],
        [B[1][0], AB[1][0]],
    ]

    CA = matmul(C, A)
    observability = [
        [C[0][0], C[0][1]],
        [CA[0][0], CA[0][1]],
    ]

    x0 = [3.0, 1.0]
    horizon = 8.0
    dt = 0.01

    open_final = euler_open_loop(A, x0, horizon, dt)
    closed_final, max_effort = euler_closed_loop(A, B, K, x0, horizon, dt)

    return ControlSystemsAudit(
        system_name="two_state_control_system_audit",
        state_names="position_like_state|velocity_like_state",
        input_names="single_control_input",
        output_names="measured_position_like_output",
        time_model="continuous_time_linear_state_space",
        state_matrix_A=matrix_to_string(A),
        input_matrix_B=matrix_to_string(B),
        output_matrix_C=matrix_to_string(C),
        feedback_matrix_K=matrix_to_string(K),
        open_loop_eigenvalues=vector_to_string(list(open_eigs)),
        closed_loop_eigenvalues=vector_to_string(list(closed_eigs)),
        open_loop_max_real_part=round(max(open_eigs), 12),
        closed_loop_max_real_part=round(max(closed_eigs), 12),
        controllability_rank=rank_2x2(controllability),
        observability_rank=rank_2x2(observability),
        open_loop_final_state=vector_to_string(open_final),
        closed_loop_final_state=vector_to_string(closed_final),
        max_control_effort=round(max_effort, 12),
        control_warning=(
            "The feedback law is evaluated without actuator saturation, delay, noise, "
            "or uncertainty. These must be reviewed before operational interpretation."
        ),
        interpretation_warning=(
            "Control models require state definition, input authority, output reliability, "
            "constraint checks, uncertainty review, objective transparency, and domain accountability."
        ),
    )


def write_outputs(output_dir: Path) -> None:
    (output_dir / "tables").mkdir(parents=True, exist_ok=True)
    (output_dir / "json").mkdir(parents=True, exist_ok=True)

    audit = build_audit()
    row = asdict(audit)

    with (output_dir / "tables" / "control_systems_audit.csv").open(
        "w", newline="", encoding="utf-8"
    ) as handle:
        writer = csv.DictWriter(handle, fieldnames=list(row.keys()))
        writer.writeheader()
        writer.writerow(row)

    (output_dir / "json" / "control_systems_audit.json").write_text(
        json.dumps(row, indent=2, sort_keys=True),
        encoding="utf-8",
    )


if __name__ == "__main__":
    write_outputs(Path("outputs"))
    print("Control systems audit complete.")

This workflow makes the intervention structure auditable: open-loop behavior, feedback behavior, controllability, observability, input effort, and interpretation warnings are recorded together.

Back to top ↑

R Workflow: Closed-Loop Diagnostics

R can support control-system diagnostics by computing open-loop and closed-loop eigenvalues, controllability and observability ranks, and finite-horizon trajectory comparisons.

A <- matrix(
  c(
    0.10, 1.00,
    0.00, 0.20
  ),
  nrow = 2,
  byrow = TRUE
)

B <- matrix(c(0.00, 1.00), nrow = 2, byrow = TRUE)
C <- matrix(c(1.00, 0.00), nrow = 1, byrow = TRUE)
K <- matrix(c(0.50, 1.40), nrow = 1, byrow = TRUE)

A_closed <- A - B %*% K

controllability <- cbind(B, A %*% B)
observability <- rbind(C, C %*% A)

matrix_rank_2x2 <- function(M, tolerance = 1e-10) {
  if (abs(det(M)) > tolerance) {
    return(2)
  }
  if (any(abs(M) > tolerance)) {
    return(1)
  }
  return(0)
}

open_eigs <- eigen(A)$values
closed_eigs <- eigen(A_closed)$values

x0 <- c(3.0, 1.0)
horizon <- 8.0
dt <- 0.01
steps <- as.integer(round(horizon / dt))

simulate_open_loop <- function(A, x0, steps, dt) {
  x <- x0
  trajectory <- matrix(NA, nrow = steps + 1, ncol = length(x0))
  trajectory[1, ] <- x
  for (k in seq_len(steps)) {
    dx <- A %*% x
    x <- x + dt * as.numeric(dx)
    trajectory[k + 1, ] <- x
  }
  trajectory
}

simulate_closed_loop <- function(A, B, K, x0, steps, dt) {
  x <- x0
  trajectory <- matrix(NA, nrow = steps + 1, ncol = length(x0))
  effort <- numeric(steps)
  trajectory[1, ] <- x
  for (k in seq_len(steps)) {
    u <- -K %*% x
    effort[k] <- max(abs(u))
    dx <- A %*% x + B %*% u
    x <- x + dt * as.numeric(dx)
    trajectory[k + 1, ] <- x
  }
  list(trajectory = trajectory, max_effort = max(effort))
}

open_traj <- simulate_open_loop(A, x0, steps, dt)
closed_result <- simulate_closed_loop(A, B, K, x0, steps, dt)
closed_traj <- closed_result$trajectory

audit_record <- data.frame(
  system_name = "two_state_control_system_audit",
  time_model = "continuous_time_linear_state_space",
  state_matrix_A = paste(round(as.vector(t(A)), 6), collapse = ","),
  input_matrix_B = paste(round(as.vector(t(B)), 6), collapse = ","),
  output_matrix_C = paste(round(as.vector(t(C)), 6), collapse = ","),
  feedback_matrix_K = paste(round(as.vector(t(K)), 6), collapse = ","),
  open_loop_eigenvalues = paste(round(Re(open_eigs), 6), collapse = ","),
  closed_loop_eigenvalues = paste(round(Re(closed_eigs), 6), collapse = ","),
  open_loop_max_real_part = max(Re(open_eigs)),
  closed_loop_max_real_part = max(Re(closed_eigs)),
  controllability_rank = matrix_rank_2x2(controllability),
  observability_rank = matrix_rank_2x2(observability),
  open_loop_final_state = paste(round(open_traj[steps + 1, ], 6), collapse = ","),
  closed_loop_final_state = paste(round(closed_traj[steps + 1, ], 6), collapse = ","),
  max_control_effort = closed_result$max_effort,
  interpretation_warning = paste(
    "Control models require input authority, output reliability, constraints,",
    "uncertainty review, objective transparency, and domain accountability."
  )
)

dir.create("outputs/tables", recursive = TRUE, showWarnings = FALSE)

write.csv(
  audit_record,
  "outputs/tables/r_control_systems_audit.csv",
  row.names = FALSE
)

trajectory_record <- data.frame(
  time = seq(0, horizon, by = dt),
  open_state_1 = open_traj[, 1],
  open_state_2 = open_traj[, 2],
  closed_state_1 = closed_traj[, 1],
  closed_state_2 = closed_traj[, 2]
)

write.csv(
  trajectory_record,
  "outputs/tables/r_control_systems_trajectories.csv",
  row.names = FALSE
)

print(audit_record)

This R workflow compares open-loop and closed-loop behavior while preserving rank diagnostics and interpretation warnings.

Back to top ↑

Haskell Workflow: Typed Control Records

Haskell can represent control-system diagnostics as typed records, keeping matrices, ranks, eigenvalue summaries, feedback assumptions, and governance warnings explicit.

module Main where

data ControlSystemsAudit = ControlSystemsAudit
  { systemName :: String
  , timeModel :: String
  , stateMatrixA :: String
  , inputMatrixB :: String
  , outputMatrixC :: String
  , feedbackMatrixK :: String
  , openLoopEigenvalues :: String
  , closedLoopEigenvalues :: String
  , controllabilityRank :: Int
  , observabilityRank :: Int
  , controlWarning :: String
  , interpretationWarning :: String
  } deriving (Show)

buildAudit :: ControlSystemsAudit
buildAudit =
  ControlSystemsAudit
    "two_state_control_system_audit"
    "continuous_time_linear_state_space"
    "0.100000,1.000000;0.000000,0.200000"
    "0.000000;1.000000"
    "1.000000,0.000000"
    "0.500000,1.400000"
    "0.200000,0.100000"
    "-0.600000,-0.600000"
    2
    2
    "The feedback law is evaluated without actuator saturation, delay, noise, or uncertainty."
    "Control models require state definition, input authority, output reliability, constraint checks, objective transparency, and domain accountability."

main :: IO ()
main =
  print buildAudit

The typed workflow helps treat control output as a structured model claim rather than a loose simulation result.

Back to top ↑

SQL Workflow: Control Assumption Registry

SQL can document control-system assumptions when models support infrastructure dashboards, control reviews, policy analysis, operational planning, platform governance, or institutional decision systems.

CREATE TABLE control_system_assumption_registry (
    assumption_key TEXT PRIMARY KEY,
    assumption_name TEXT NOT NULL,
    mathematical_role TEXT NOT NULL,
    systems_modeling_role TEXT NOT NULL,
    review_warning TEXT NOT NULL
);

INSERT INTO control_system_assumption_registry VALUES
(
  'state_definition',
  'State definition',
  'Defines the internal coordinates of the control model.',
  'Determines what the controller is trying to regulate.',
  'Poorly defined states can make feedback target the wrong behavior.'
);

INSERT INTO control_system_assumption_registry VALUES
(
  'input_authority',
  'Input authority',
  'Defines the channels represented by the input matrix B.',
  'Determines what interventions are available.',
  'Mathematical input channels may not be physically, legally, or institutionally available.'
);

INSERT INTO control_system_assumption_registry VALUES
(
  'output_reliability',
  'Output reliability',
  'Defines what is measured through the output matrix C.',
  'Determines what information feedback uses.',
  'Noisy, biased, delayed, or incomplete outputs can destabilize decisions.'
);

INSERT INTO control_system_assumption_registry VALUES
(
  'controllability',
  'Controllability',
  'Tests whether inputs can influence state-space directions.',
  'Shows whether the model can move the system through relevant states.',
  'Rank alone does not account for cost, constraints, or authority.'
);

INSERT INTO control_system_assumption_registry VALUES
(
  'observability',
  'Observability',
  'Tests whether outputs reveal internal state directions.',
  'Shows whether feedback can infer what needs to be controlled.',
  'Hidden unstable modes are serious safety and governance risks.'
);

INSERT INTO control_system_assumption_registry VALUES
(
  'feedback_objective',
  'Feedback objective',
  'Defines what the controller is designed to achieve.',
  'Encodes performance, cost, safety, or optimization priorities.',
  'Control objectives are value choices and should be documented.'
);

INSERT INTO control_system_assumption_registry VALUES
(
  'constraints',
  'Constraints',
  'Defines input, state, rate, delay, and feasibility limits.',
  'Determines whether the control law can actually be applied.',
  'Ignoring saturation or delay can invalidate closed-loop analysis.'
);

SELECT
    assumption_name,
    mathematical_role,
    systems_modeling_role,
    review_warning
FROM control_system_assumption_registry
ORDER BY assumption_key;

This registry keeps control systems modeling tied to state definition, input authority, output reliability, rank diagnostics, feedback objectives, constraints, and responsible intervention.

Back to top ↑

GitHub Repository

The companion repository for this article is designed as a reproducible mathematical-modeling workspace. It supports control-system audits, open-loop and closed-loop stability diagnostics, controllability and observability rank reports, feedback simulation, input-effort review, SQL governance tables, generated outputs, advanced mathematical audit reports, and reusable calculator scripts.

Back to top ↑

Interpretive Limits and Responsible Use

Control systems modeling is powerful because it connects system representation to intervention. It can reveal whether a system can be stabilized, whether inputs reach relevant states, whether outputs reveal internal conditions, whether feedback changes eigenstructure, and whether a controller improves response over a simulated horizon. Its limits arise because real systems have constraints, delays, uncertainty, noise, nonlinearities, saturation, unmodeled variables, strategic behavior, institutional limits, and contested objectives.

A control model can be physical, engineering-based, empirical, local, scenario-based, or policy-oriented. These uses require different evidence. A controller designed for a laboratory motor is not the same as a policy intervention in an adaptive social system. A mathematically controllable model is not necessarily controllable in the real world. A stable closed-loop matrix is not automatically safe, equitable, legitimate, or acceptable.

Responsible use requires documenting state definitions, units, inputs, outputs, matrix sources, time model, feedback law, objectives, constraints, uncertainty, controllability, observability, stability, control effort, actuator limits, measurement quality, delays, validation evidence, and governance accountability. Control systems should make intervention more transparent, not disguise power, values, uncertainty, or consequences behind matrices.

Back to top ↑

Back to top ↑

Further Reading

Back to top ↑

References

Back to top ↑

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top