Figure 2.22:

Bifurcation diagram for the saddle-node bifurcation.

Code for Figure 2.22

Text of the GNU GPL.

main.py


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import numpy as np
import matplotlib.pyplot as plt

npts = 51
y1 = np.linspace(0, 1, npts)
y2 = -y1
x = y1**2

plt.plot(x, y1, '-')
plt.plot(x, y2, '.')
plt.axis([-0.25, 1.25, -1.1, 1.1])
plt.show(block=False)

table = np.column_stack((x, y1, y2))
with open("snbm.dat", "w") as f:
    np.savetxt(f, table, fmt='%f', header="x y1 y2")