Analysis · Orbit & bifurcation diagrams
Orbit & bifurcation diagrams¶
An orbit diagram plots sampled long-term states against a control parameter.
It can reveal period doubling, periodic windows and changes between attractors.
orbit_diagram works with discrete-time systems and views; return_map plots
successive values of a recurring observable. Both are finite-sample summaries,
so check transient length, parameter spacing and initial conditions.
The idea¶
For a map \(x_{n+1} = f(x_n; \mu)\) the orbit diagram records, at each value of \(\mu\), the set of states the orbit visits once transients have died away. Where the attractor is a fixed point you see one dot; a period-2 cycle gives two, a period-4 cycle four, and a chaotic band fills a vertical stripe. Sweeping \(\mu\) draws the bifurcation diagram — the map of how that attractor is created, doubled, and destroyed as the parameter moves.
Nothing about the construction is specific to maps. Any object that advances in
discrete steps works, and sys.poincare(...) turns a flow into exactly such an
object: given a plane it samples the flow at the crossings, given a period it
strobes a forced oscillator once per drive cycle. An orbit diagram over either
is the bifurcation diagram of the flow.
Maps: the logistic cascade¶
The logistic map \(x_{n+1} = r\,x_n(1 - x_n)\) is the canonical example.
orbit_diagram takes the system, the parameter name, and the values to sweep:
import numpy as np
import tsdynamics as ts
od = ts.analysis.orbit_diagram(
ts.systems.Logistic(),
"r", np.linspace(2.5, 4.0, 600),
points_per_value=120, # states recorded per r
transient=500, # steps discarded first, at every r
)
param, state = od.flat() # scatter-ready arrays
flat() returns two aligned 1-D arrays — the parameter value repeated once per
recorded point, and the asymptotic state — ready to scatter as
plt.plot(param, state, ",k"). The result is an OrbitDiagram: iterate it for
(value, points) pairs, index its .values / .points, and it carries the
usual .meta / .to_dict() / .plot result surface. transient is a step
count discarded before recording; points_per_value is how many states you keep, enough to
resolve the widest band you care about.
How to read it¶
Left of \(r = 3\) the orbit sits on a single branch — a stable fixed point. At \(r_1 = 3\) that fixed point loses stability and the branch forks: the orbit now alternates between two values (period 2). At \(r_2 = 1 + \sqrt{6} \approx 3.449\) each branch forks again (period 4), then 8, 16, … in a geometric cascade that accumulates at \(r_\infty \approx 3.5699\) — the onset of chaos. Beyond it the diagram is mostly chaotic bands, punctured by periodic windows: the wide one near \(r \approx 3.83\) is the period-3 window born at the tangent bifurcation \(r = 1 + \sqrt{8}\), itself period-doubling as \(r\) increases.
Following the attractor: carry_state¶
By default (carry_state=True) each parameter value starts from the previous
value's final state. This walks the attractor branch continuously and produces
clean diagrams without re-converging through a transient basin at every step —
the standard way to draw the picture above. Set carry_state=False to restart
every value from the same ic. With coexisting attractors, compare several
initial conditions and sweep directions: neither a single carried branch nor
a single fixed initial condition reveals all basins. The swept system is never mutated — each
value gets a fresh with_params copy.
Quantifying the cascade¶
Counting distinct branches at each \(r\) is reading off the period, and
OrbitDiagram.periods() automates it. bifurcation_points() then turns the
changes into estimated onset parameters:
od = ts.analysis.orbit_diagram(
ts.systems.Logistic(), "r", np.linspace(2.9, 3.6, 400), points_per_value=64, transient=2000,
)
od.periods() # period at each r: 1, 2, 4, …, 0 (aperiodic), -1 (diverged)
od.bifurcation_points() # → ≈ [3.00, 3.45, …] the period-doubling onsets
periods() clusters each value's recorded points with a scale-free gap
test — a new branch begins wherever the sorted-value gap exceeds rtol times
the orbit's range — then confirms a candidate period \(p\) by checking that the
iterate sequence actually revisits its values cyclically (\(v_i \approx
v_{i+p}\)). That second test is what keeps a chaotic band whose finite sample
happens to fall into \(p\) bins from being mislabelled a period-\(p\) window. Counts
above max_period are reported as 0 (aperiodic); a diverged value is -1.
For the logistic map the first two onsets land on the textbook values \(r_1 = 3\)
and \(r_2 = 1 + \sqrt{6} \approx 3.449\). The resolution of
bifurcation_points() is the spacing of the swept values, so sweep finely
near a transition to pin it down.
Named components
When the system declares variables, the component selector accepts a
name as well as an index, and periods() / bifurcation_points() take the
same selector to count branches in a chosen coordinate.
Flows: bifurcation diagrams by composition¶
orbit_diagram requires a discrete view, and a flow does not have one on its
own — so derive one. sys.poincare(...) presents the flow as the map of its
crossings through a section plane; sweeping a parameter of that is a
bifurcation diagram of the flow, one section crossing per "iteration":
od = ts.analysis.orbit_diagram(
ts.systems.Rossler().poincare("y", 0.0), # section y = 0, crossed upward
"c", np.linspace(4.0, 6.0, 120),
points_per_value=60, transient=30,
)
c, x_cross = od.flat() # parameter values, then x-coordinate of the crossings
with_params re-parametrizes the inner Rössler system and rebuilds the
wrapper, so the sweep composes transparently. The Rössler period-doubling route
to its funnel attractor appears here just as the logistic cascade does — the
same cascade, one dimension up.
For a periodically forced oscillator the natural section is a strobe once
per forcing period — the same poincare verb, given a period instead of a plane:
duf = ts.systems.Duffing() # forcing frequency omega = 1.4
od = ts.analysis.orbit_diagram(
duf.poincare(period=2 * np.pi / 1.4),
"gamma", np.linspace(0.30, 0.50, 120),
points_per_value=40, transient=60,
)
A plane is an affine surface \(g(\mathbf{u}) = \mathbf{n}\cdot\mathbf{u} - c\);
a period samples the phase circle. They are different sections of the same flow,
so poincare takes exactly one of them and says so if you give both.
Each sample is the state after exactly one drive period, so a period-1 response (locked to the forcing) is a single point, a period-2 subharmonic is two, and chaos fills a band — the forced-oscillator counterpart of the logistic diagram.
Diverging parameter values
A single value whose orbit blows up does not abort the sweep: that value
records an empty point set and emits a RuntimeWarning, and the sweep
continues. If a whole range of a forced system diverges, you are outside its
bounded-response regime — narrow the range.
The hidden 1-D map: return_map¶
A bifurcation diagram shows where the dynamics live; a return map shows
how they move. It records successive values of one recurring scalar and plots
each against its successor \((v_n, v_{n+1})\), exposing the effective
one-dimensional map that organises the flow. return_map builds it two ways.
The classic construction (Lorenz, 1963) records successive local maxima of a coordinate:
rm = ts.analysis.return_map(ts.systems.Lorenz(), "z", kind="max",
final_time=400.0, transient=40.0)
vn, vn1 = rm.flat()
# plt.plot(vn, vn1, ".") # the famous single-humped z-maxima cusp map
The Lorenz \(z\)-maxima form a narrow curve, supporting an approximate scalar return relation. Recorded values are sharpened by parabolic interpolation of each peak's three samples, so a coarse detection step still locates the extremum accurately.
The other construction records an observable at successive section crossings — the section's own return map:
rm = ts.analysis.return_map(ts.systems.Rossler(), "y", kind="poincare",
plane=("x", 0.0, "up"), n=400)
Either source can be a live system (integrated for you), an existing
Trajectory, or — for the extremum methods — a bare 1-D array. A ReturnMap
can also draw its own cobweb (rm.cobweb()), the staircase that traces the
iteration \(v_{n+1} = F(v_n)\) against the diagonal. A filled cloud may indicate
unresolved state variables or noisy observations; a scalar plot cannot decide
between them on its own.
Cost notes¶
- Maps — a genuine
DiscreteMapsweeps the whole parameter array in a single Rust engine call (the map is lowered once, the kernel varies the parameter per value), so hundred- and thousand-value sweeps are routine and fast. - ODE-backed wrappers — parameter changes are control parameters of the lowered tape, so the per-value cost is just the integration; no re-lowering.
- DDE-backed sweeps — each parameter value re-lowers the delay equation (its structure depends on all parameters). Budget accordingly, or sweep coarsely first to find the interesting window.
See also¶
- Poincaré sections — the section machinery behind
sys.poincare(...), andreturn_map(kind="poincare") - Fixed points & periodic orbits — the invariant sets that are born and lost at the bifurcations above
- Lyapunov spectra — the exponent that turns positive as the cascade reaches chaos
- Integration & methods — simulation, solver settings and incremental stepping
References¶
- May, R. M. (1976). Simple mathematical models with very complicated dynamics. Nature 261, 459–467.
- Feigenbaum, M. J. (1978). Quantitative universality for a class of nonlinear transformations. J. Stat. Phys. 19, 25–52.
- Lorenz, E. N. (1963). Deterministic nonperiodic flow. J. Atmos. Sci. 20, 130–141.