2D Spirals

Status: Running
● Animation Active

What Am I Looking At?

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)(xteσ(t))+eσ(t)\mathbf{x}_{t+1} = \mathbf{A}_{\sigma(t)} \cdot (\mathbf{x}_t - \mathbf{e}_{\sigma(t)}) + \mathbf{e}_{\sigma(t)}
where σ(t){0,1}\sigma(t) \in \{0, 1\} selects which "rule" to apply
Ai=kiR(θi(t))\mathbf{A}_i = k_i \cdot \mathbf{R}(\theta_i(t)) defines the transformation for rule ii

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)\sigma(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:

Ai(θi)=ki[cos(θi)sin(θi)sin(θi)cos(θi)]\mathbf{A}_i(\theta_i) = k_i \begin{bmatrix} \cos(\theta_i) & -\sin(\theta_i) \\\\ \sin(\theta_i) & \cos(\theta_i) \end{bmatrix}
kiR+k_i \in \mathbb{R}^+ : scaling factor (controls spiral tightness)
θi(t)=θi0+ωit\theta_i(t) = \theta_i^0 + \omega_i t : rotation angle that increases with time

Key insight: When ki<1k_i < 1, the transformation shrinks distances, creating a spiral that converges toward the equilibrium. When ki>1k_i > 1, it expands them, creating outward spirals. The rotation angle θi(t)\theta_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 PtransP_{\text{trans}} to decide whether to change rules:

P(σ(t+1)σ(t))=Ptrans\mathbb{P}(\sigma(t+1) \neq \sigma(t)) = P_{\text{trans}}
s(t)Bernoulli(Ptrans)s(t) \sim \text{Bernoulli}(P_{\text{trans}}) : coin flip at each time step
σ(t)=(σ(t1)+s(t))mod2\sigma(t) = (\sigma(t-1) + s(t)) \bmod 2 : 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 PtransP_{\text{trans}} 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\text{Stable when } |k_i| < 1
limtxtei=0\lim_{t \to \infty} \|\mathbf{x}_t - \mathbf{e}_i\| = 0 (trajectory spirals into equilibrium)
Switched System Behavior:
Complex stability depends on ikipi<1\text{Complex stability depends on } \prod_i k_i^{p_i} < 1
where pip_i is the long-run proportion in mode ii

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]\mathbf{e}_0 = \begin{bmatrix} x_0 \\\\ y_0 \end{bmatrix}, \quad \mathbf{e}_1 = \begin{bmatrix} x_1 \\\\ y_1 \end{bmatrix}
Rule 0: xt+1=k0R(θ0(t))(xte0)+e0\mathbf{x}_{t+1} = k_0 \mathbf{R}(\theta_0(t)) (\mathbf{x}_t - \mathbf{e}_0) + \mathbf{e}_0
Rule 1: xt+1=k1R(θ1(t))(xte1)+e1\mathbf{x}_{t+1} = k_1 \mathbf{R}(\theta_1(t)) (\mathbf{x}_t - \mathbf{e}_1) + \mathbf{e}_1

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)\theta_0(t) and θ1(t)\theta_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\theta_i(t) = \theta_i^0 + \omega_i t — 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,k1k_0, k_1 (scaling factors): Control spiral tightness. Try k<1k < 1 for inward spirals, k>1k > 1 for outward spirals
  • PtransP_{\text{trans}} (transition probability): Low values = organized spirals, high values = chaotic behavior
  • e0,e1\mathbf{e}_0, \mathbf{e}_1 (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 kk values to 0.9 and Ptrans=0.1P_{\text{trans}} = 0.1 for tight, organized spirals
  • Try k0=0.8,k1=1.1k_0 = 0.8, k_1 = 1.1 to see competing inward/outward spirals
  • Set Ptrans=0.5P_{\text{trans}} = 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!