Skip to content

Commit 35ae370

Browse files
committed
new file: Experimental_Dev/amplitude.py
1 parent 2164c8c commit 35ae370

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

Experimental_Dev/amplitude.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import matplotlib.pyplot as plt
2+
import numpy as np
3+
from numba import njit
4+
5+
6+
@njit
7+
def hopalong_attractor(a, b, c, iterations=None):
8+
x_vals = np.zeros(iterations)
9+
y_vals = np.zeros(iterations)
10+
11+
x, y = 0.0, 0.0 # Initial values
12+
13+
for i in range(iterations):
14+
x, y = y - np.sign(x) * np.sqrt(abs(b * x - c)) , a - x
15+
16+
x_vals[i] = x
17+
y_vals[i] = y
18+
19+
return x_vals, y_vals
20+
21+
22+
def plot_hopalong_combined(x_vals, y_vals):
23+
iterations = range(len(x_vals))
24+
amplitude = np.sqrt(np.diff(x_vals, prepend=x_vals[0])**2 + np.diff(y_vals, prepend=y_vals[0])**2)
25+
26+
plt.figure(figsize=(12, 10))
27+
28+
plt.subplot(2, 2, 1, aspect='equal')
29+
plt.scatter(x_vals, y_vals, s=0.5, c='blue', alpha=0.7)
30+
plt.title("Hopalong Attractor")
31+
plt.xlabel("X")
32+
plt.ylabel("Y")
33+
plt.grid(True)
34+
35+
plt.subplot(2, 1, 2)
36+
plt.plot(iterations, amplitude, label="Amplitude (Point Distance)", color="blue", alpha=0.7)
37+
plt.title("Amplitude of Hopalong Attractor Over Events")
38+
plt.xlabel("Iteration Index")
39+
plt.ylabel("Amplitude (Distance)")
40+
plt.xscale('log')
41+
plt.grid(True)
42+
plt.legend()
43+
44+
plt.tight_layout()
45+
plt.show()
46+
47+
def main():
48+
49+
a, b, c = 0.7, 0.4, 0
50+
iterations = 10000000
51+
52+
x_vals, y_vals = hopalong_attractor(a, b, c, iterations)
53+
54+
plot_hopalong_combined(x_vals, y_vals)
55+
56+
57+
if __name__ == "__main__":
58+
main()
59+
60+
61+

0 commit comments

Comments
 (0)