Skip to content

Instantly share code, notes, and snippets.

@Miladiouss
Created February 22, 2019 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Miladiouss/8ce1b0944521f19c471121da8e5990ff to your computer and use it in GitHub Desktop.
Save Miladiouss/8ce1b0944521f19c471121da8e5990ff to your computer and use it in GitHub Desktop.
Simple code for bifurcation of logistic map
# Library import for plotting
import matplotlib.pyplot as plt
%matplotlib inline
# Define Logistic Map
def f(x, r):
return r * x * (1 - x)
# Define history and parameters
history = [0.5]
num_iter = 400
# =========================
# Try 3.4, 3.5, 3.6, 3.7
r = 3.4
# =========================
# Iterate
for n in range(400):
x_old = history[-1]
x_new = f(x_old, r)
history.append(x_new)
# Plot
plt.scatter(range(num_iter + 1), history)
plt.ylim((0, 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment