How to loop parameter "a" in Henon map?

250 Views Asked by At

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()
```
1

There are 1 best solutions below

4
On BEST ANSWER

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.

a=np.linspace(0,1.4,50000)
b=np.linspace(0.27,0.3,4)
x = [1/(1-b)]*2
for an in a[2:]:
    x.append(1-an*x[-1]**2+b*x[-2])

x = np.asarray(x)
plt.plot(a,x,'o',ms=1)
plt.legend(b); plt.grid(); 
plt.tight_layout(); plt.show()

This gives the plot enter image description here

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.