Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Error encountered while generating bifurcation diagram

$
0
0

Bifurcation diagram error>Hello. I am currently studying the paper "(Nonlinear dynamics in the Cournot duopolygame with heterogeneous players)" by (H.N. Agiza, A.A. Elsadany) and trying to implement the bifurcation diagram in Python. However, I am encountering an error and I think there are errors in my mathematical input and code. Would it be possible to help me?(The equation I entered is equation (13) in the paper, which can be found on page 516.)

# Parametersa = 10.0  # Parameter ab = 0.5  # Parameter bc1 = 3.0  # Parameter c1c2 = 5.0  # Parameter c2# Alpha value rangealpha_min = 0.0  # Minimum alpha valuealpha_max = 5.0  # Maximum alpha valuealpha_step = 0.1  # Alpha value step# Alpha values listalpha_values = np.arange(alpha_min, alpha_max, alpha_step)def q1(alpha):  q1_prev = 0.0  # Initialize q1_prev  for i in range(iterations):    q1_next = q1_prev + alpha * q1_prev(a - c1 - 2 * b * q1_prev - b * q2(alpha))      q1_prev = q1_next  return q1_nextdef q2(alpha):  return 1 / (2 * b) * (a - c2 - b * q1(alpha))def bifurcation_diagram():  # Data storage lists  q1_vals = []  q2_vals = []  for alpha in alpha_values:    # Initial value setting    q1 = 0.5    q2 = 0.5    # Simulation execution    for i in range(iterations):      q1_next = q1(alpha)  # Pass current alpha to q1 function      q2_next = q2(alpha)  # Pass current alpha to q2 function      # Data storage      if i > 100:        q1_vals.append(q1_next)        q2_vals.append(q2_next)      # Update to the next value      q1 = q1_next      q2 = q2_next  # Plotting  plt.plot(alpha_values, q1_vals, label="q1")  plt.plot(alpha_values, q2_vals, label="q2")  plt.legend()  plt.show()# Number of iterationsiterations = 5000# Generate bifurcation diagrambifurcation_diagram()

I am still a beginner, so I lack in many areas.I think there are errors in my mathematical input and code.Would it be possible to help me?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>