Linear ODE System Solver: dx/dt = Ax Step by Step
A linear system of ordinary differential equations has the form dx/dt = A·x, where A is a constant matrix. This solver finds the general solution using eigenvalues and eigenvectors, classifies the equilibrium at the origin, and can solve initial value problems when x(0) is provided. These systems model everything from spring-mass systems to population dynamics and electrical circuits.
Calculator
Enter your matrix below and click "Calculate" to see the step-by-step solution.
Solution
Step-by-step solution with explanations.
Enter a matrix and click "Calculate" to see results here.
Learn About Linear_Ode_System
Understanding the concepts behind the calculations.
Linear System of ODEs: Complete Guide with Step-by-Step Solutions
Quick Navigation
- What is a Linear System of ODEs?
- The General Solution Method
- Classification of Equilibrium Points
- Stability Analysis
- Phase Portraits: Visualizing Solutions
- Real-World Applications
- Step-by-Step Examples
- Special Cases
- Frequently Asked Questions
- Practice Problems
- Related Topics
What is a Linear System of ODEs?
Definition
A linear system of ordinary differential equations (ODEs) with constant coefficients is a system of the form:
$$ \frac{d\mathbf{x}}{dt} = A\mathbf{x} $$
Where:
- $\mathbf{x}(t)$ is a vector of $n$ unknown functions $[x_1(t), x_2(t), \dots, x_n(t)]^T$.
- $A$ is an $n \times n$ constant matrix.
- The system is homogeneous (no external forcing term).
Component Form
For a 2D system ($n=2$), this expands to:
$$ \begin{aligned} \frac{dx_1}{dt} &= a_{11}x_1 + a_{12}x_2 \ \frac{dx_2}{dt} &= a_{21}x_1 + a_{22}x_2 \end{aligned} $$
The Matrix Exponential Solution
The general solution to this system is given by the matrix exponential:
$$ \mathbf{x}(t) = e^{At}\mathbf{x}(0) $$
However, computing $e^{At}$ directly is difficult. Instead, we use eigenvalues and eigenvectors to construct the solution explicitly.
The General Solution Method
The form of the solution depends on the eigenvalues $\lambda$ of the matrix $A$.
Case 1: Distinct Real Eigenvalues
If $A$ has distinct real eigenvalues $\lambda_1, \dots, \lambda_n$ with corresponding eigenvectors $\mathbf{v}_1, \dots, \mathbf{v}_n$, the general solution is:
$$ \mathbf{x}(t) = c_1 \mathbf{v}_1 e^{\lambda_1 t} + c_2 \mathbf{v}_2 e^{\lambda_2 t} + \dots + c_n \mathbf{v}_n e^{\lambda_n t} $$
Case 2: Complex Conjugate Eigenvalues
If $A$ has complex eigenvalues $\lambda = \alpha \pm i\beta$ with eigenvector $\mathbf{v} = \mathbf{a} \pm i\mathbf{b}$, the real-valued general solution involves sines and cosines:
$$ \mathbf{x}(t) = c_1 e^{\alpha t} (\mathbf{a} \cos(\beta t) - \mathbf{b} \sin(\beta t)) + c_2 e^{\alpha t} (\mathbf{a} \sin(\beta t) + \mathbf{b} \cos(\beta t)) $$
Case 3: Repeated Eigenvalues (Defective Matrix)
If an eigenvalue $\lambda$ has algebraic multiplicity $k$ but fewer than $k$ linearly independent eigenvectors, we must find generalized eigenvectors. For a defect of 1 (one missing eigenvector):
$$ \mathbf{x}(t) = c_1 \mathbf{v} e^{\lambda t} + c_2 (\mathbf{v}t + \mathbf{w}) e^{\lambda t} $$
Where $\mathbf{w}$ is a generalized eigenvector satisfying $(A - \lambda I)\mathbf{w} = \mathbf{v}$.
Classification of Equilibrium Points
The origin $\mathbf{x}=\mathbf{0}$ is always an equilibrium point. Its type is determined by the eigenvalues of $A$ (for 2D systems).
| Eigenvalues ($\lambda_1, \lambda_2$) | Type | Stability | Phase Portrait Shape |
|---|---|---|---|
| Real, $\lambda_1 < \lambda_2 < 0$ | Stable Node | Asymptotically Stable | Trajectories approach origin along straight lines |
| Real, $0 < \lambda_1 < \lambda_2$ | Unstable Node | Unstable | Trajectories diverge from origin |
| Real, $\lambda_1 < 0 < \lambda_2$ | Saddle Point | Unstable | Approaches along one axis, diverges along other |
| Complex, $\text{Re}(\lambda) < 0$ | Stable Spiral | Asymptotically Stable | Spirals into origin |
| Complex, $\text{Re}(\lambda) > 0$ | Unstable Spiral | Unstable | Spirals away from origin |
| Purely Imaginary, $\text{Re}(\lambda) = 0$ | Center | Lyapunov Stable | Closed elliptical orbits |
| Repeated, Defective | Improper Node | Depends on sign | Parabolic trajectories |
Stability Analysis
Stability Definitions
| Term | Meaning | Mathematical Definition |
|---|---|---|
| Asymptotically stable | Solutions approach origin as $t \to \infty$ | $\lim_{t \to \infty} |\mathbf{x}(t)| = 0$ |
| Lyapunov stable | Solutions stay near origin if started near it | $|\mathbf{x}(0)| < \delta \implies |\mathbf{x}(t)| < \epsilon$ |
| Unstable | At least one solution moves away from origin | Not stable |
Stability Criterion (General n)
| Condition | Stability |
|---|---|
| All eigenvalues have $\text{Re}(\lambda) < 0$ | Asymptotically stable |
| All eigenvalues have $\text{Re}(\lambda) \leq 0$, and those with $\text{Re}=0$ are non-defective | Lyapunov stable |
| Any eigenvalue has $\text{Re}(\lambda) > 0$ | Unstable |
Phase Portraits: Visualizing Solutions
What is a Phase Portrait?
A phase portrait shows solution curves (trajectories) in the state space (e.g., the $x_1$-$x_2$ plane for 2D systems). It provides a geometric understanding of the system's behavior without solving for specific time values.
Reading Phase Portraits
Direction of time: Arrows indicate increasing $t$.
- Arrows point toward origin → stable
- Arrows point away from origin → unstable
Trajectory shapes:
- Straight lines → Motion along eigenvectors
- Curves → Linear combinations of modes
- Closed loops → Periodic solutions (centers)
- Spirals → Complex eigenvalues with non-zero real part
How to Sketch by Hand (2D)
- Find eigenvalues $\lambda_1, \lambda_2$ and eigenvectors $\mathbf{v}_1, \mathbf{v}_2$.
- Draw eigenvector lines through the origin.
- Determine flow direction:
- If $\lambda > 0$, arrows point away from origin along that eigenvector.
- If $\lambda < 0$, arrows point toward origin.
- Sketch sample trajectories that are tangent to the dominant eigenvector (largest $|\lambda|$) near the origin.
Real-World Applications
🏗️ Engineering: Spring-Mass Systems
A two-mass spring system can be modeled as a second-order system, which converts to a 4-dimensional first-order linear system:
$$ \frac{d}{dt}\begin{bmatrix} x_1 \ x_2 \ v_1 \ v_2 \end{bmatrix} = \left[\begin{array}{cccc} 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ -\frac{k_1+k_2}{m_1} & \frac{k_2}{m_1} & 0 & 0 \\ \frac{k_2}{m_2} & -\frac{k_2}{m_2} & 0 & 0 \end{array}\right] \begin{bmatrix} x_1 \ x_2 \ v_1 \ v_2 \end{bmatrix} $$
Eigenvalues give natural frequencies: $\omega = \sqrt{|\lambda|}$ (for imaginary eigenvalues).
🧬 Biology: Predator-Prey Models (Linearized)
Near an equilibrium point, the non-linear Lotka-Volterra equations can be linearized:
$$ \frac{d}{dt}\begin{bmatrix} P \ Q \end{bmatrix} = \left[\begin{array}{cc} \alpha & -\beta \\ -\delta & \gamma \end{array}\right] \begin{bmatrix} P \ Q \end{bmatrix} $$
Eigenvalues determine: Oscillation frequencies and stability of the ecosystem.
🔌 Electrical Engineering: RLC Circuits
A series RLC circuit is governed by a second-order ODE, which converts to a 2D linear system:
$$ \frac{d}{dt}\begin{bmatrix} q \ i \end{bmatrix} = \left[\begin{array}{cc} 0 & 1 \\ -\frac{1}{LC} & -\frac{R}{L} \end{array}\right] \begin{bmatrix} q \ i \end{bmatrix} $$
Eigenvalues tell you:
- Complex $\lambda$: Underdamped (oscillates)
- Real distinct $\lambda$: Overdamped
- Real repeated $\lambda$: Critically damped
🚀 Control Theory: State-Space Models
Any linear control system is written as: $$ \dot{\mathbf{x}} = A\mathbf{x} + B\mathbf{u} $$ The homogeneous part $\dot{\mathbf{x}} = A\mathbf{x}$ determines the natural stability of the system. If $A$ has any eigenvalue with positive real part, the open-loop system is unstable.
Step-by-Step Examples
Example 1: Stable Node (Both $\lambda$ Negative)
System: $$ \frac{d\mathbf{x}}{dt} = \left[\begin{array}{cc} -2 & 0 \\ 0 & -1 \end{array}\right] \mathbf{x} $$
Step 1: Find eigenvalues Since the matrix is diagonal, $\lambda_1 = -2,\quad \lambda_2 = -1$.
Step 2: Find eigenvectors $$ \mathbf{v}_1 = \left[\begin{array}{c} 1 \\ 0 \end{array}\right],\quad \mathbf{v}_2 = \left[\begin{array}{c} 0 \\ 1 \end{array}\right] $$
Step 3: General solution $$ \mathbf{x}(t) = c_1 \left[\begin{array}{c} 1 \\ 0 \end{array}\right] e^{-2t} + c_2 \left[\begin{array}{c} 0 \\ 1 \end{array}\right] e^{-t} $$
Step 4: Classification
- Type: Stable node (sink)
- Stability: Asymptotically stable
- Behavior: All trajectories approach the origin. The $x_1$ direction decays faster ($\lambda = -2$) than the $x_2$ direction ($\lambda = -1$).
Example 2: Saddle Point (Mixed Signs)
System: $$ \frac{d\mathbf{x}}{dt} = \left[\begin{array}{cc} 1 & 0 \\ 0 & -2 \end{array}\right] \mathbf{x} $$
Step 1: Find eigenvalues $$ \lambda_1 = 1,\quad \lambda_2 = -2 $$
Step 2: General solution $$ \mathbf{x}(t) = c_1 \left[\begin{array}{c} 1 \\ 0 \end{array}\right] e^{t} + c_2 \left[\begin{array}{c} 0 \\ 1 \end{array}\right] e^{-2t} $$
Step 3: Classification
- Type: Saddle point
- Stability: Unstable
- Behavior: Trajectories approach the origin along the $x_2$-axis (stable manifold, $\lambda_2 < 0$) but diverge along the $x_1$-axis (unstable manifold, $\lambda_1 > 0$).
Example 3: Stable Spiral (Complex $\lambda$ with $\alpha < 0$)
System: $$ \frac{d\mathbf{x}}{dt} = \left[\begin{array}{cc} -1 & -2 \\ 2 & -1 \end{array}\right] \mathbf{x} $$
Step 1: Find eigenvalues Characteristic equation: $(\lambda+1)^2 + 4 = 0 \Rightarrow \lambda = -1 \pm 2i$. Here $\alpha = -1, \beta = 2$.
Step 2: Find eigenvector for $\lambda = -1 + 2i$ Solving $(A - \lambda I)\mathbf{v} = 0$ yields $\mathbf{v} = \left[\begin{array}{c} 1 \\ -i \end{array}\right] = \left[\begin{array}{c} 1 \\ 0 \end{array}\right] + i\left[\begin{array}{c} 0 \\ -1 \end{array}\right]$. So $\mathbf{a} = [1, 0]^T$ and $\mathbf{b} = [0, -1]^T$.
Step 3: General real solution $$ \mathbf{x}(t) = c_1 e^{-t} \left( \left[\begin{array}{c} 1 \\ 0 \end{array}\right] \cos(2t) - \left[\begin{array}{c} 0 \\ -1 \end{array}\right] \sin(2t) \right) + c_2 e^{-t} \left( \left[\begin{array}{c} 1 \\ 0 \end{array}\right] \sin(2t) + \left[\begin{array}{c} 0 \\ -1 \end{array}\right] \cos(2t) \right) $$
Step 4: Classification
- Type: Stable spiral
- Stability: Asymptotically stable
- Behavior: Solutions spiral into the origin with frequency 2 rad/s.
Example 4: Defective Matrix (Repeated $\lambda$, One Eigenvector)
System: $$ A = \left[\begin{array}{cc} 2 & 1 \\ 0 & 2 \end{array}\right] $$
Step 1: Find eigenvalues $\det(A-\lambda I) = (2-\lambda)^2 = 0 \Rightarrow \lambda = 2$ (multiplicity 2).
Step 2: Find eigenvectors $(A - 2I)\mathbf{v} = \left[\begin{array}{cc} 0 & 1 \\ 0 & 0 \end{array}\right]\mathbf{v} = \mathbf{0} \Rightarrow \mathbf{v}_1 = \left[\begin{array}{c} 1 \\ 0 \end{array}\right]$. Only one independent eigenvector exists.
Step 3: Find generalized eigenvector $\mathbf{w}$ Solve $(A - 2I)\mathbf{w} = \mathbf{v}_1$: $$ \left[\begin{array}{cc} 0 & 1 \\ 0 & 0 \end{array}\right] \left[\begin{array}{c} w_1 \\ w_2 \end{array}\right] = \left[\begin{array}{c} 1 \\ 0 \end{array}\right] \implies w_2 = 1 $$ We can choose $w_1 = 0$, so $\mathbf{w} = \left[\begin{array}{c} 0 \\ 1 \end{array}\right]$.
Step 4: General solution $$ \mathbf{x}(t) = c_1 \left[\begin{array}{c} 1 \\ 0 \end{array}\right] e^{2t} + c_2 \left( \left[\begin{array}{c} 1 \\ 0 \end{array}\right]t + \left[\begin{array}{c} 0 \\ 1 \end{array}\right] \right) e^{2t} $$
Step 5: Classification
- Type: Improper node (source)
- Stability: Unstable ($\lambda > 0$)
Example 5: Initial Value Problem
System: Same as Example 1 with IC: $\mathbf{x}(0) = [1, 2]^T$.
Step 1: General solution $$ x_1(t) = c_1 e^{-2t},\quad x_2(t) = c_2 e^{-t} $$
Step 2: Apply initial conditions ($t = 0$) $$ x_1(0) = c_1 = 1 \implies c_1 = 1 $$ $$ x_2(0) = c_2 = 2 \implies c_2 = 2 $$
Step 3: Particular solution $$ x_1(t) = e^{-2t},\quad x_2(t) = 2e^{-t} $$
Special Cases
Case: Zero Matrix ($A = 0$)
System: $\frac{d\mathbf{x}}{dt} = \mathbf{0}$ Solution: $\mathbf{x}(t) = \mathbf{x}(0)$ (Constant) Classification: Every point is an equilibrium (degenerate).
Case: Nilpotent Matrix
Example: $$ A = \left[\begin{array}{ccc} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \end{array}\right] $$ Property: $A^3 = 0$. The matrix exponential series terminates: $$ e^{At} = I + At + \frac{1}{2}A^2t^2 $$
Case: Skew-Symmetric Matrix
Example: $$ A = \left[\begin{array}{cc} 0 & -1 \\ 1 & 0 \end{array}\right] $$ Property: $A^T = -A$. Eigenvalues are purely imaginary ($\pm i$). Result: Center (stable periodic orbits). Energy is conserved.
Frequently Asked Questions
Q: Why do we need eigenvalues for ODEs?
A: Eigenvalues determine the growth rate and oscillation frequency of the system. They tell you if the system will explode, decay, or oscillate without solving the entire time history.
Q: What if $A$ has complex eigenvalues?
A: The solution will involve sine and cosine terms, representing oscillation. The real part of the eigenvalue determines if the oscillation grows (unstable) or decays (stable).
Q: What is the difference between algebraic and geometric multiplicity?
A:
- Algebraic: How many times $\lambda$ appears as a root of the characteristic polynomial.
- Geometric: The number of linearly independent eigenvectors for $\lambda$.
- If Geometric < Algebraic, the matrix is defective, and you need generalized eigenvectors.
Q: Can I solve non-homogeneous systems ($\dot{\mathbf{x}} = A\mathbf{x} + \mathbf{f}(t)$)?
A: Yes, using variation of parameters: $$ \mathbf{x}(t) = e^{At}\mathbf{x}(0) + \int_0^t e^{A(t-s)} \mathbf{f}(s) ds $$
Q: How do I know if my system is stable?
A: Check the real parts of all eigenvalues:
- All $\text{Re}(\lambda) < 0$ → Asymptotically stable
- Any $\text{Re}(\lambda) > 0$ → Unstable
- $\text{Re}(\lambda) = 0$ → Marginally stable (if non-defective)
Practice Problems
Beginner Level
- Find eigenvalues: For $A = \left[\begin{array}{cc} -3 & 0 \\ 0 & -5 \end{array}\right]$, classify the equilibrium.
- Write system: Write $\frac{d}{dt}[x_1, x_2]^T = \left[\begin{array}{cc} 1 & 2 \\ 3 & 4 \end{array}\right][x_1, x_2]^T$ as two separate equations.
Intermediate Level
- Solve completely: Find the general solution for $\frac{d\mathbf{x}}{dt} = \left[\begin{array}{cc} 1 & 1 \\ 1 & 1 \end{array}\right] \mathbf{x}$.
- Complex eigenvalues: Solve $\frac{d\mathbf{x}}{dt} = \left[\begin{array}{cc} 0 & -1 \\ 1 & 0 \end{array}\right] \mathbf{x}$ and classify the equilibrium.
Advanced Level
- Defective matrix: Find the general solution for $A = \left[\begin{array}{cc} 2 & 1 \\ 0 & 2 \end{array}\right]$.
- Initial Value Problem: Solve $\frac{d\mathbf{x}}{dt} = \left[\begin{array}{cc} -2 & 1 \\ 0 & -2 \end{array}\right] \mathbf{x}$ with $\mathbf{x}(0) = [1, 1]^T$.
Summary
Key Takeaways
| Concept | Summary |
|---|---|
| System form | $\frac{d\mathbf{x}}{dt} = A\mathbf{x}$ |
| General solution | Linear combination of $e^{\lambda t}$ times eigenvectors |
| Stability | Determined by signs of $\text{Re}(\lambda)$ |
| Phase portrait | Geometric picture of trajectories in state space |
| Fundamental matrix | $\Phi(t) = e^{At}$ (columns are basis solutions) |
Algorithm for Solving
- Compute eigenvalues $\lambda$ of matrix $A$.
- Compute eigenvectors $\mathbf{v}$ (and generalized if needed).
- Build solution components:
- Real distinct: $c \mathbf{v} e^{\lambda t}$
- Complex: $e^{\alpha t}(\cos(\beta t)\mathbf{a} - \sin(\beta t)\mathbf{b})$
- Repeated/defective: Include polynomials $t^k e^{\lambda t}$
- Combine with constants for general solution.
- Apply Initial Conditions (if given) to find particular solution.
Related Topics
Explore these related concepts in our Linear Algebra Toolbox:
- Eigenvalue/Eigenvector Calculator - Core of ODE solution method
- Matrix Exponential Calculator - Direct computation of $e^{At}$
- Diagonalization Calculator - Simplifies ODEs when $A = PDP^{-1}$
- Phase Portrait Visualizer - See the geometry of solutions
Try It Yourself!
Use the calculator above to explore linear ODE systems:
- Enter your matrix A (2×2 to 4×4)
- Optional: Add initial condition $\mathbf{x}(0)$
- Click "Calculate" to see:
- General solution (symbolic)
- Particular solution (if IC given)
- Eigenvalues and eigenvectors
- Equilibrium classification
- Stability analysis
Test these examples:
Stable node (sink): $$ A = \left[\begin{array}{cc} -2 & 0 \\ 0 & -1 \end{array}\right] $$
Saddle point: $$ A = \left[\begin{array}{cc} 1 & 0 \\ 0 & -2 \end{array}\right] $$
Stable spiral: $$ A = \left[\begin{array}{cc} -1 & -2 \\ 2 & -1 \end{array}\right] $$
Center (periodic): $$ A = \left[\begin{array}{cc} 0 & -2 \\ 2 & 0 \end{array}\right] $$
Defective (Jordan block): $$ A = \left[\begin{array}{cc} 2 & 1 \\ 0 & 2 \end{array}\right] $$
Check initial condition: Try $\mathbf{x}(0) = [1, 0]^T$ with the stable node example to see exponential decay!
Pro tip: The eigenvalues tell you everything about system behavior:
- Negative real parts → decay to equilibrium
- Positive real parts → growth/instability
- Imaginary parts → oscillations
- Zero real parts → marginal stability