Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- import numpy
- import matplotlib.pyplot as plt
- def f(r, x):
- return r * x - x ** 3
- def get_orbit(r, initial_x, amount, iterations, digits):
- points = deque([f(r, initial_x)], amount)
- for _ in range(iterations):
- points.append(round(f(r, points[-1]), digits))
- return set(points)
- def build_diagram(initial_x, start, end, step):
- x = []
- y = []
- for r in numpy.arange(start, end, step):
- orbit = get_orbit(r, initial_x, 20, 100, 5)
- for i in orbit:
- x.append(r)
- y.append(i)
- plt.figure(figsize=(30, 30))
- plt.scatter(x, y, s=1)
- plt.show()
- if __name__ == "__main__":
- build_diagram(0.01, 0, 3, 0.001)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement