Appendix B: Computational Methods and Phase Portrait Blueprint

This appendix provides the computational tools for numerically integrating the model systems, computing equilibria, and producing phase portraits for the models developed in these notes. At the present stage this appendix is a computational blueprint: it records the numerical protocols and selected sweep values, but it does not include a complete set of figures. The code extends the attractor-figure script used to generate the Chapter 0 phase portrait (submission/rebuild_attractor_figure.py) to handle the general Code Test-state, Code Test-action template of Chapter 2.

No new theorems appear here. The purpose is to give the reader a self-contained computational pipeline for reproducing the qualitative attractor phenomena described in Chapters 0, 10, and 11, and to specify which phase portraits, basin slices, and parameter sweeps should be generated before making numerical basin claims.

B.1 Numerical Integration of the Model System

The ODE has the form

Code Test

A general-purpose integrator takes the model data Code Test and a generator family Code Test as input, and produces trajectories. Here the law equation carries the timescale parameter Code Test of Chapter 2, Code Test; the shipped Chapter 0 figure of Section B.3 uses Code Test.

RK4 integration. The standard fourth-order Runge-Kutta method applies without modification to the Code Test-components. The distribution component Code Test requires care: after each integration step, Code Test must remain on the simplex Code Test. Because the generator equation Code Test preserves the simplex exactly in continuous time, the RK4 approximation stays close to the simplex for small time steps. For robustness, we project Code Test back onto Code Test after each step: set any negative component to zero and renormalize.

The existing rebuild_attractor_figure.py implements this for the Chapter 0 model with Code Test and Code Test. The extension to general Code Test requires:

  1. Replacing the hard-coded rhs function with one that computes the softmax policy, occupancy measure, critic coefficients, actor drift, and generator dynamics from the data tuple Code Test and the current state.
  2. Replacing the scalar damping Code Test with the diagonal matrix Code Test.
  3. Adding the simplex projection after each RK4 step.

The computational cost per step is Code Test for the softmax and drift evaluation, plus Code Test for the generator dynamics. For the models in these notes (Code Test, Code Test, Code Test), a single trajectory of length Code Test with step size Code Test requires roughly Code Test evaluations and runs in milliseconds.

Implementation note. The integrator should accept the model data as a structured input (a dictionary or data class with fields for Code Test, Code Test, Code Test, Code Test, Code Test, Code Test, Code Test, and the generator matrices Code Test) and return time series for all state components. This makes it straightforward to switch between the Chapter 0, Chapter 10, and Chapter 11 models by changing only the data input.

B.2 Equilibrium Finding and Nullcline Computation

Equilibrium finding. An equilibrium satisfies Code Test, which is a system of Code Test equations. For the models in these notes, this system has dimension at most 8 (the Chapter 10 model). Newton’s method applies: starting from an initial guess Code Test, iterate

Code Test

where Code Test is the Jacobian of the vector field. The Jacobian can be computed analytically (from the derivatives of the softmax, the critic coefficients, and the generator) or numerically (by finite differences). For the models here, numerical differentiation is adequate.

Boundary equilibria. With a multi-dimensional actor the damping matrix Code Test vanishes only at a corner, where every coordinate is saturated. At a corner the actor equation is automatic, and the remaining system–the critic equation Code Test and the distribution equation Code Test–is linear and can be solved directly. On an open face, where only some coordinates satisfy Code Test, the damping kills only the saturated coordinates’ drift; each unsaturated coordinate still requires its raw drift to vanish, Code Test in the notation of Chapter 10, a nonlinear root-finding problem of the same kind as the interior case (Section 10.6 locates the Chapter 10 A-bubble this way, at Code Test with Code Test). For Code Test (the Chapter 0 and Chapter 11 models) every boundary point of the actor box is a corner, so the linear shortcut applies.

Interior equilibria require solving the full nonlinear system. A practical approach: first solve the reduced system on the invariant-law graph (where Code Test and Code Test), which is a system in Code Test alone (dimension Code Test). For Code Test (the routing model), this is a scalar root-finding problem. For Code Test (the recommendation model), it is a two-dimensional root-finding problem. Then lift the solution to the full phase space by computing Code Test and Code Test.

Nullcline computation. A nullcline of the Code Test-th component is the surface Code Test. In the Code Test-plane at fixed Code Test, nullclines are curves that can be computed by sweeping: for each value of Code Test on a grid, solve Code Test for Code Test (or vice versa). The intersections of the Code Test-nullcline and the Code Test-nullcline are the equilibria.

For the Chapter 0 model, the nullclines in the Code Test-plane are already familiar from Section 0.14. For the Chapter 10 and 11 models, the nullclines live in higher-dimensional spaces and must be visualized as slices.

B.3 Phase Portrait Blueprint: The Chapter 0 and Section 2.8 Models

Chapter 0 asymmetric model (the existing figure). The attractor figure already shipped with the paper plots the asymmetric two-state model (Code Test, Code Test): three trajectories, two of them starting outside the absorbing set Code Test, all enter Code Test and converge numerically to a single interior equilibrium at Code Test. A completed extended figure set should include:

  • The Code Test-phase portrait with nullclines, multiple initial conditions, and the interior equilibrium marked, together with the two boundary equilibria at Code Test where the damping vanishes.
  • Time series of Code Test, Code Test, and Code Test along one trajectory, showing the initial transient and the approach to the interior equilibrium.
  • The Code Test-plane at Code Test, showing how the distribution coordinate co-evolves with the actor.

Chapter 0 symmetric model (planned figure item). The symmetric model (Code Test), whose interior equilibrium sits at Code Test, is generated by adapting the asymmetric figure script (Exercise 0.9). A useful plot is a set of time series Code Test launched from several initial conditions, used to explore numerically whether trajectories from different regions all approach the interior equilibrium or are instead captured by the boundary equilibria at Code Test–the boundary-stability question that Chapter 0, Section 0.14 leaves open. The plot records numerical observations, not a proved basin classification.

Chapter 0 asymmetric model (Code Test). Breaking the reward symmetry by varying Code Test from 0 to 2 produces a parameter sweep:

  • For small Code Test (e.g., Code Test), the asymmetry shifts the interior equilibrium and changes the relative sizes of the basins.
  • For Code Test, the symmetric case is recovered.
  • For Code Test, the opposite asymmetry appears.

The sweep illustrates how the attractor’s internal structure responds continuously to parameter changes.

Section 2.8 routing model. The three-state model with scalar actor and critic produces a Code Test-phase portrait qualitatively similar to Chapter 0 but with different equilibrium locations driven by the routing rewards. The computation plan includes:

  • The Code Test-portrait at the frozen invariant law Code Test.
  • A comparison of the three-state and five-state (Chapter 11) phase portraits, showing how the additional states change the equilibrium structure.

B.4 Phase Portrait Blueprint: The Recommendation and Routing Models

All basin and stability statements in this blueprint and in the parameter sweeps of Section B.5 are numerical observations in the sense of Section B.3, not proved classifications.

Chapter 10 recommendation model. The eight-dimensional phase space requires slicing. The most informative views are:

  • Code Test-plane at the critic and distribution equilibrium: set Code Test and Code Test, and plot the reduced actor drift as a vector field in the Code Test-square Code Test. The four equilibria (diverse, A-bubble, B-bubble, dual bubble) should be marked as fixed points. Any basin boundaries shown in this slice are numerical evidence, not a theorem.

  • Basin boundary map: Color each point Code Test by which equilibrium the trajectory from Code Test converges to. The resulting colored plot would show the basins of the four equilibria in that chosen slice.

  • Parameter sweep: varying Code Test (the diversity reward). For Code Test ranging from 0.1 to 1.0, recompute the interior equilibrium, the saturated-face transverse signs, and the basin boundaries in the chosen slice.

  • Parameter sweep: varying the deep-engagement exit rate. Increasing the exit rate from states 3 and 5 in both generators (making it easier for users to leave deep engagement) tests whether the boundary configurations become more or less transversely attractive.

Chapter 11 routing model. The six-dimensional phase space is easier to slice because Code Test:

  • Code Test-phase portrait at Code Test: the reduced system is two-dimensional and can be plotted directly. The three equilibria (left-spoke, right-spoke, interior) should be marked.

  • Code Test-plane: how the hub traffic fraction co-evolves with the routing policy. At the interior equilibrium, Code Test is substantial; at the spoke-heavy equilibria, Code Test is small.

  • Time series comparison: overlay trajectories starting from hub-heavy, left-heavy, and right-heavy initial distributions to test which equilibria the trajectories approach in the chosen regime.

  • Comparison with the three-state model: side-by-side phase portraits of the Section 2.8 and Chapter 11 models, highlighting how the additional states create competing spoke-heavy attractors.

B.5 Parameter Continuation and Bifurcation Sketches

The attractor’s sensitivity to model parameters is best seen through continuation: track how the equilibria and their basins change as one parameter varies continuously.

Method. For each parameter value on a grid, compute all equilibria (boundary and interior) using the methods of Section B.2. Plot the equilibrium coordinates as functions of the parameter. Mark stability changes (where an equilibrium gains or loses stability) and equilibrium creation or destruction (where two equilibria collide and annihilate).

This is not a formal bifurcation analysis — we do not compute normal forms or classify the bifurcation type. For those tools, a good entry point is Kuznetsov, Elements of Applied Bifurcation Theory, Chapters 2—3, or, for the one-parameter pitchfork picture, Strogatz, Nonlinear Dynamics and Chaos, Chapter 3. The purpose here is visual: to show the reader how the attractor landscape responds to design choices.

Chapter 10: deep-engagement reward sweep. Vary Code Test (the reward for curating in deep-niche states) from 0.5 to 2.0. As the deep-niche reward increases:

  • The saturated-face transverse sign should be recomputed at each reward value. Only after that sign reverses should the boundary configuration be described as attracting from the interior.
  • The interior equilibrium should be tracked as the reward changes; symmetry breaking may move it off the diagonal.
  • Basin claims should be made only from the corresponding colored slice or a higher-dimensional sampling table.

Chapter 11: hub reward sweep. Vary Code Test (the hub reward for both actions) from 0.1 to 1.0. This sweep is instructive because it is a lever that does not work: the common hub reward cancels in the reward-advantage term, Code Test for every Code Test (Exercise 11.7(c)), so it enters only through the critic forcing Code Test. Numerically, the balanced equilibrium’s attraction weakens slightly as the hub reward rises: the slope Code Test of the bracket function Code Test of Section 11.5 moves from Code Test at Code Test to Code Test at Code Test (Section 11.6). The spoke-heavy boundary equilibria persist (they are created by damping, not by rewards). The plot shows the equilibria barely move under this sweep, in contrast with the secondary matching reward sweep, which moves the regime decisively.

Chapter 11: secondary matching reward sweep. Vary Code Test on a grid from 1.0 to 4.0 and recompute the bracket function Code Test at each value. Plot Code Test and the boundary values Code Test, Code Test against Code Test, marking the pitchfork threshold Code Test where Code Test changes sign (the balanced equilibrium loses stability, and a mirror pair of attracting interior equilibria splits off) and the lock-in threshold Code Test where the boundary values change sign (spoke lock-in becomes stable). This is the sweep cited in Sections 11.5—11.6, and it identifies the secondary reward asymmetry as the lever that actually moves the regime.

Chapter 11: topology sweep. Vary the direct hub-to-secondary rate by adding a shortcut edge from H to C with increasing rate. This changes the network topology continuously and shows how a shortcut that bypasses the primary node affects the attractor structure.

These computational experiments complement the analytical results of Chapters 10 and 11. The analysis identifies the equilibria and their character (boundary versus interior, damping-created versus gradient-zero). The computations described here are the route for quantifying basin structure and its response to design choices.