mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 06:57:17 -05:00
Create comprehensive research-lab pack structure with mathematical and quantum computing modules from blackroad-prism-console: Math Modules: - hilbert_core.py: Hilbert space symbolic reasoning - collatz/: Distributed Collatz conjecture verification - linmath/: Linear mathematics C library - lucidia_math_forge/: Symbolic proof engine - lucidia_math_lab/: Experimental mathematics Quantum Modules: - lucidia_quantum/: Quantum core - quantum_engine/: Circuit simulation Experiments: - br_math/: Gödel gap, quantum experiments Includes pack.yaml manifest and comprehensive README. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
"""Fractal generators for the Lucidia Math Forge.
|
|
|
|
The :func:`generate_fractal` function accepts a recursion rule and writes
|
|
a simple fractal image to disk. Rules operate on complex numbers and
|
|
are intentionally simple to keep execution fast in constrained
|
|
environments.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Callable
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
|
|
def julia_rule(z: complex, c: complex) -> complex:
|
|
"""Default Julia set rule ``z^2 + c``."""
|
|
|
|
return z * z + c
|
|
|
|
|
|
def generate_fractal(
|
|
rule: Callable[[complex, complex], complex] = julia_rule,
|
|
filename: str = "fractal.png",
|
|
iterations: int = 50,
|
|
bounds=(-2.0, 2.0, -2.0, 2.0),
|
|
resolution: int = 300,
|
|
) -> str:
|
|
"""Generate a fractal image using ``rule`` and save it to ``filename``."""
|
|
|
|
xmin, xmax, ymin, ymax = bounds
|
|
x = np.linspace(xmin, xmax, resolution)
|
|
y = np.linspace(ymin, ymax, resolution)
|
|
c = x[:, None] + 1j * y[None, :]
|
|
z = np.zeros_like(c)
|
|
mask = np.ones(c.shape, dtype=bool)
|
|
|
|
for _ in range(iterations):
|
|
z[mask] = rule(z[mask], c[mask])
|
|
mask &= np.abs(z) < 2
|
|
|
|
plt.imshow(mask.T, extent=bounds, cmap="magma")
|
|
plt.axis("off")
|
|
plt.savefig(filename, bbox_inches="tight", pad_inches=0)
|
|
plt.close()
|
|
return filename
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Create a quick Julia set image.
|
|
print("Saved fractal to", generate_fractal())
|