leftovers

This commit is contained in:
2026-05-12 11:53:02 +02:00
parent e181656f04
commit 275ca96e74
12 changed files with 1316 additions and 1 deletions
+9
View File
@@ -9,5 +9,14 @@
<Property name="Executable" value="C:\Users\Sebastian\Desktop\INF6B\simulations\donut.c\donut.exe" />
<Property name="Arguments" value="" />
</Option>
<Option name="RestoreBreakpoints">
<Property name="Breakpoints" />
</Option>
<Option name="RestoreCommandHistory">
<Property name="History">
<Property value="p" />
<Property value="help" />
</Property>
</Option>
</TargetOptions>
</TargetConfig>
+41
View File
@@ -0,0 +1,41 @@
import numpy as np
import matplotlib.pyplot as plt
# Setting parameters (these values can be changed)
x_domain, y_domain = np.linspace(-2, 2, 500), np.linspace(-2, 2, 500)
bound = 2
max_iterations = 50 # any positive integer value
colormap = "nipy_spectral" # set to any matplotlib valid colormap
func = lambda z, p, c: z**p + c
# Computing 2D array to represent the Mandelbrot set
iteration_array = []
for y in y_domain:
row = []
for x in x_domain:
z = 0
p = 2
c = complex(x, y)
for iteration_number in range(max_iterations):
if abs(z) >= bound:
row.append(iteration_number)
break
else:
try:
z = func(z, p, c)
except (ValueError, ZeroDivisionError):
z = c
else:
row.append(0)
iteration_array.append(row)
# Plotting the data
ax = plt.axes()
ax.set_aspect("equal")
graph = ax.pcolormesh(x_domain, y_domain, iteration_array, cmap=colormap)
plt.colorbar(graph)
plt.xlabel("Real-Axis")
plt.ylabel("Imaginary-Axis")
plt.show()