I am trying to draw a Henon map (Henon attractor) based on the Python 3 code in this link https://blbadger.github.io/henon-map.html. The different point is that links fixes a=1.4, b=0.3. I want to draw a figure with parameter "a" in the range (0,1.4) rather than a fix a=1.4.
I modified the code as follows. Even though there is no error, I received nothing. Could anyone please let me know what should I do to get the figure of Henon attractor? Thanks!
def henon_attractor(x, y, a, b=0.3):
for a in range(0, 1.4):
x_next = 1 - a * x ** 2 + y
y_next = b * x
return x_next, y_next
# number of iterations and array initialization
steps = 3000
X = np.zeros(steps + 1)
Y = np.zeros(steps + 1)
# initial point
X[0], Y[0] = 0, 0
# add points to array
for i in range(steps):
x_next, y_next = henon_attractor(X[i], Y[i])
X[i+1] = x_next
Y[i+1] = y_next
plt.plot(X, Y, 'o', color='red', alpha = 0.8, markersize=2)
plt.title('Henon attractor (b=0.3)')
plt.xlabel('x')
plt.ylabel('y')
fig1 = plt.gcf()
plt.show()
```
The Henon dynamic is, when reduced to one dimension, of order 2 with recursion formula $$ x_{n+1}=1-ax_n^2+bx_{n-1}. $$
The plots of the Henon attractor then are of pairs $(x_n,x_{n-1})$ (which invites the idea for 3D plots of triples $(x_n,x_{n-1},x_{n-2})$).
For $a=0$ the fixed point is at $x=\frac1{1-b}$.
The paper then makes the process "adiabatically" dynamic by slowly increasing $a$ to $1.4$, to then plot the points $(a_n,x_n)$. In a short Python script this can be achieved as follows.
This gives the plot
This could of course also be done for each $b$ separately. Adding noise will make the plot more "stochastic", but will change little of the dynamical picture.