Skip to content

Real quadratic automaton

The automaton τ(x)(n) = x(n + 1) - x(n)^2 over the reals on a ring.

  • Class: RealQuadraticAutomatonSystem
  • Import: from skcomplex.systems.computer_science.automata import RealQuadraticAutomatonSystem
  • Field: computer_science/automata
  • Topics: lattice, infinite alphabet, reals, pre-injective
  • References:
    • Ceccherini-Silberstein and Coornaert 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.computer_science.automata import RealQuadraticAutomatonSystem

trajectory = RealQuadraticAutomatonSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
size 64
amplitude 0.25
initial None
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 lattice
Laws update
Randomness unknown
Domains real
Structure fixed

Class

The source of the class shows how it builds its components from its model parameters.

class RealQuadraticAutomatonSystem(BaseSystem):
    """The automaton `τ(x)(n) = x(n + 1) - x(n)^2` over the reals on a ring.

    It is pre-injective but not injective, since the constant configurations 0 and 1 both map to 0, and its image is
    dense but neither closed nor everything (Ceccherini-Silberstein and Coornaert 2023, Exercise 5.64). The square pulls
    the cells down at every step, and cells far from the origin run off to minus infinity. The system has the cells
    `cells.value`.

    Args:
        size:
            The number of cells of the ring.

        amplitude:
            The half width of the uniform initial values.

        initial:
            The initial values, or `None` for random ones.

        random_state:
            The seed or generator of the random initial values.

        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.computer_science.automata import RealQuadraticAutomatonSystem
        >>> RealQuadraticAutomatonSystem(8).prepare().simulate(until=1).get_values('cells.value').shape
        (2, 8)
    """

    field = 'computer_science/automata'
    topics = ('lattice', 'infinite alphabet', 'reals', 'pre-injective')
    references = ('Ceccherini-Silberstein and Coornaert 2023',)
    until = 6
    dt = 1

    def __init__(
        self,
        size: int = 64,
        *,
        amplitude: float = 0.25,
        initial: npt.ArrayLike | None = None,
        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.size = size
        self.amplitude = amplitude
        self.initial = initial
        self.random_state = random_state

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of a ring of real cells and the quadratic rule."""
        super()._prepare(context)
        if self.initial is None:
            values = np.random.default_rng(self.random_state).uniform(-self.amplitude, self.amplitude, self.size)
        else:
            values = np.asarray(self.initial, dtype=float)
        self.system_ = System(
            self.label,
            elements=[RealCellElement('cells', value=values, space=LatticeSpace(self.size))],
            interactions=[QuadraticRuleInteraction('quadratic', target='cells')],
        )

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

Interactions:

  • QuadraticRuleInteraction, from Interaction
class RealCellElement(Element):
    """Cell of an automaton over the real numbers.

    With `space`, the element holds one cell on every site.

    Args:
        label:
            The label of the cells.

        value:
            The initial value, or one value per cell.

        space:
            The space with one cell on every site, such as a lattice, or `None` for one cell.

    Examples:
        >>> from skcomplex.systems.computer_science.automata import RealCellElement
        >>> RealCellElement('cell', value=0.5).value
        0.5
    """

    def __init__(
        self,
        label: str,
        *,
        value: Annotated[float | Array, RR] = 0.0,
        space: BaseSpace | None = None,
    ) -> None:
        super().__init__(label, space=space)
        self.value = value

class QuadraticRuleInteraction(Interaction):
    """Rule `τ(x)(n) = x(n + 1) - x(n)^2` of cells holding real numbers.

    Args:
        label:
            The label of the interaction.

        target:
            The cells whose state `value` the rule changes.

    Examples:
        >>> from skcomplex.systems.computer_science.automata import QuadraticRuleInteraction
        >>> QuadraticRuleInteraction('quadratic', target='cells').target
        'cells'
    """

    def __init__(self, label: str, *, target: Role = 'cells') -> None:
        super().__init__(label)
        self.target = target

    @staticmethod
    def _get_quadratic(here: Array, right: Array, **kwargs: object) -> Array:
        """Return `x(n + 1) - x(n)^2`."""
        return right - here**2

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the rule on a cell and the cell to its right as the law.

        Args:
            context:
                The namespace of the elements a binding of the roles names.
        """
        super()._prepare(context)
        value = context.target.value
        self.laws_: list[BaseLaw] = [
            UpdateLaw(value, self._get_quadratic, neighborhood=FORWARD, label=self.label),
        ]