Random complex square-root function system
The random function system z -> ±√(z - omega).
- Class:
InverseJuliaSystem - Import:
from skcomplex.systems.mathematics.fractals import InverseJuliaSystem - Field:
mathematics/fractals - Topics:
fractal,complex,iterated function system,random map,julia set - References:
- Barnsley 1988
- Dilão 2023
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.mathematics.fractals import InverseJuliaSystem
trajectory = InverseJuliaSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
omega |
(-0.123+0.745j) |
p |
0.5 |
n_points |
5000 |
random_state |
0 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | discrete |
| Space | none |
| Laws | update |
| Randomness | stochastic |
| Domains | complex |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class InverseJuliaSystem(BaseSystem):
"""The random function system `z -> ±√(z - omega)`.
Its points settle on the Julia set of `z² + omega`.
At every step each point moves to the positive square root of `z - omega` with probability `p` and to the negative
one otherwise (Dilão 2023, Exercise 5.8). Both branches invert the quadratic map `z -> z² + omega`, which repels its
Julia set, so the inverse branches attract the points onto the Julia set, drawn by the chaos game with weights `p`
and `1 - p`. For `omega = 0` the Julia set is the unit circle, and the default is Douady's rabbit. The system has
the points `points.z`.
Args:
omega:
The constant of the quadratic map.
p:
The probability of the positive square root.
n_points:
The number of points, started uniformly in the square of side 2 about the origin.
random_state:
The seed or generator of the initial points.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Examples:
>>> from skcomplex.systems.mathematics.fractals import InverseJuliaSystem
>>> InverseJuliaSystem(0.0, n_points=10).prepare().system_.elements[0].size
10
"""
field = 'mathematics/fractals'
topics = ('fractal', 'complex', 'iterated function system', 'random map', 'julia set')
references = ('Barnsley 1988', 'Dilão 2023')
until = 30
dt = 1
def __init__(
self,
omega: complex = -0.123 + 0.745j,
*,
p: float = 0.5,
n_points: int = 5000,
random_state: int | np.random.Generator | None = 0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.omega = omega
self.p = p
self.n_points = n_points
self.random_state = random_state
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the points and their random inverse map."""
super()._prepare(context)
rng = np.random.default_rng(self.random_state)
start = rng.uniform(-1.0, 1.0, self.n_points) + 1j * rng.uniform(-1.0, 1.0, self.n_points)
inverse = InverseJuliaInteraction('inverse', target='points', omega=complex(self.omega), p=self.p)
self.system_ = System(
self.label,
elements=[InverseJuliaPointElement('points', z=start, size=self.n_points)],
interactions=[inverse],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
InverseJuliaPointElement, fromElement
Interactions:
InverseJuliaInteraction, fromInteraction
class InverseJuliaPointElement(Element):
"""Points of the inverse iteration of `z -> z² + omega`, each with its point `z`.
An `InverseJuliaInteraction` moves every point to a square root of `z - omega` drawn at random.
Args:
label:
The label of the points.
z:
The initial point, one per member or shared.
size:
The number of points, or `None` for one.
Examples:
>>> from skcomplex.systems.mathematics.fractals import InverseJuliaPointElement
>>> InverseJuliaPointElement('point', z=0.5j).z
0.5j
"""
def __init__(self, label: str, *, z: object = 0.5, size: int | None = None) -> None:
super().__init__(label, size=size)
self.z = z
class InverseJuliaInteraction(Interaction):
"""Move of a point to a random square root of `z - omega`.
The point moves to `+√(z - omega)` with probability `p` and to `-√(z - omega)` otherwise, with the principal square
root, drawn anew at every step for every member of a bound group.
Args:
label:
The label of the interaction.
target:
The points whose value `z` the interaction moves.
omega:
The constant of the quadratic map.
p:
The probability of the positive square root.
Examples:
>>> from skcomplex.systems.mathematics.fractals import InverseJuliaInteraction
>>> InverseJuliaInteraction('inverse', p=0.3).p
0.3
"""
law_classes = (UpdateLaw,)
draws = True
def __init__(
self,
label: str,
*,
target: Role = 'points',
omega: complex = 0.0,
p: float = 0.5,
) -> None:
super().__init__(label)
self.target = target
self.omega = omega
self.p = p
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the move to the square root drawn in the step as the law.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
z = context.target.z
root = sqrt(z - context.omega)
self.laws_: list[BaseLaw] = [UpdateLaw(z, (2 * bernoulli('branch', context.p) - 1) * root)]
Equations
The equations are those that symbolic returns for the system with its default parameters.
points.z[i].real: z_points_re(t + 1) == ((omega_inverse_im - z_points_im(t))^2 + (omega_inverse_re - z_points_re(t))^2)^(1/4)*(2*where(bernoulli_branch_inverse < p_inverse, 1, 0) - 1)*cos(1/2*arctan2(-omega_inverse_im + z_points_im(t), -omega_inverse_re + z_points_re(t)))
points.z[i].imag: z_points_im(t + 1) == ((omega_inverse_im - z_points_im(t))^2 + (omega_inverse_re - z_points_re(t))^2)^(1/4)*(2*where(bernoulli_branch_inverse < p_inverse, 1, 0) - 1)*sin(1/2*arctan2(-omega_inverse_im + z_points_im(t), -omega_inverse_re + z_points_re(t)))