This interactive visualization explores switched linear dynamical systems — mathematical models where a system alternates between different linear behaviors based on random switching. Watch as trajectories create beautiful spiral patterns while jumping between two competing equilibrium points.
The Mathematics Behind the Spirals
At its core, this system represents a discrete-time switched linear dynamical system. Think of it as a point moving in 2D space, where at each time step, the system randomly chooses between two different "rules" for how to move the point. Each rule tries to pull the point toward a different center while rotating it, creating the mesmerizing spiral patterns.
The Core Equation
The position of our point at the next time step is determined by this fundamental equation:
xt+1=Aσ(t)⋅(xt−eσ(t))+eσ(t)
where σ(t)∈{0,1} selects which "rule" to apply
Ai=ki⋅R(θi(t)) defines the transformation for rule i
This equation says: "Take the current position, subtract the equilibrium point, apply a rotation and scaling, then add the equilibrium point back." The switching signal σ(t) randomly chooses between the two different transformations.
The Transformation Matrices
Each transformation combines rotation with scaling. The magic happens because we have two differenttransformation matrices, each trying to pull the point toward a different equilibrium:
θi(t)=θi0+ωit : rotation angle that increases with time
Key insight: When ki<1, the transformation shrinks distances, creating a spiral that converges toward the equilibrium. When ki>1, it expands them, creating outward spirals. The rotation angle θi(t) changes over time, which is why you see the spiral patterns evolving.
How the Switching Works
The system doesn't just randomly pick between the two rules—it uses a clever switching mechanism. At each time step, it flips a coin with probability Ptrans to decide whether to change rules:
P(σ(t+1)=σ(t))=Ptrans
s(t)∼Bernoulli(Ptrans) : coin flip at each time step
σ(t)=(σ(t−1)+s(t))mod2 : toggle between rules 0 and 1
This creates persistence in the switching—the system tends to stay with the same rule for multiple time steps before switching. Low Ptrans values create long sequences with the same rule (more organized spirals), while high values create rapid switching (more chaotic behavior).
Why Do We Get Spirals?
The Stability Story
The beautiful spiral patterns emerge from a fascinating stability phenomenon. Each individual "rule" (when applied alone) has predictable behavior:
Individual Rule Behavior:
Stable when ∣ki∣<1
limt→∞∥xt−ei∥=0 (trajectory spirals into equilibrium)
Switched System Behavior:
Complex stability depends on i∏kipi<1
where pi is the long-run proportion in mode i
The magical insight: Even when both individual rules are stable (would spiral inward), the switching between different equilibrium points can destabilize the overall system! This creates the persistent, evolving spiral patterns you see—the system never settles down because it keeps changing targets.
The Competing Attractors
The heart of the system is the tension between two competing "attractors"—points that want to pull the trajectory toward them:
e0=x0y0,e1=x1y1
Rule 0: xt+1=k0R(θ0(t))(xt−e0)+e0
Rule 1: xt+1=k1R(θ1(t))(xt−e1)+e1
Imagine two whirlpools in different locations, each trying to draw objects toward their center while spinning them. The trajectory gets caught between these competing forces, creating intricate patterns as it alternately approaches one whirlpool then the other. The time-varying rotation angles θ0(t) and θ1(t)ensure the "whirlpools" are constantly changing their spin, preventing the system from ever settling into a simple pattern.
Why the Patterns Keep Evolving
The system never reaches a steady state because it combines three sources of complexity:
🌀 Time-varying rotation:θi(t)=θi0+ωit — the "spin" of each whirlpool changes continuously
🎲 Random switching: The system unpredictably jumps between the two rules
⚖️ Competing equilibria: Two different "targets" pull the trajectory in different directions
This makes the system both time-varying (parameters change with time) and stochastic(involves randomness). The result is a system that exhibits bounded complexity—it never settles down, but it also never explodes to infinity. Instead, it creates these mesmerizing, ever-changing spiral patterns.
Experiment and Explore
Use the control panel to explore how different parameters affect the spiral patterns:
Parameter Guide:
k0,k1 (scaling factors): Control spiral tightness. Try k<1 for inward spirals, k>1 for outward spirals
e0,e1 (equilibrium points): Move the "whirlpool centers" to see how distance affects patterns
Visual controls: Customize colors, dot size, and glow effects to highlight different aspects of the motion
Try These Experiments:
Set both k values to 0.9 and Ptrans=0.1 for tight, organized spirals
Try k0=0.8,k1=1.1 to see competing inward/outward spirals
Set Ptrans=0.5 for maximum chaos
Move the equilibrium points far apart to see long-range switching effects
Each parameter combination reveals different aspects of this rich mathematical system. The beauty lies in how such complex, evolving patterns emerge from surprisingly simple rules!