Fractal models: Standard-precision implementations

Standard precision implementations are limited by float64 format precision.

class fractalshades.models.Mandelbrot(directory: str)[source]
__init__(directory: str)[source]

A standard power-2 Mandelbrot Fractal.

\[\begin{split}z_0 &= 0 \\ z_{n+1} &= z_{n}^2 + c\end{split}\]
Parameters:
directorystr

Path for the working base directory

calc_std_div(*, calc_name: str = 'base_calc', subset: Fractal_array | None = None, max_iter: int = 10000, M_divergence: float = 1000.0, epsilon_stationnary: float = 0.01, calc_d2zndc2: bool = False, calc_orbit: bool = False, backshift: int = 0)[source]

Basic iterations for Mandelbrot standard set (power 2).

Parameters:
calc_namestr

The string identifier for this calculation

subsetOptional fractalshades.postproc.Fractal_array

A boolean array-like, where False no calculation is performed If None, all points are calculated. Defaults to None.

max_iterint

the maximum iteration number. If reached, the loop is exited with exit code “max_iter”.

M_divergencefloat

The diverging radius. If reached, the loop is exited with exit code “divergence”

epsilon_stationnaryfloat

A small criteria (typical range 0.01 to 0.001) used to detect earlier points belonging to a minibrot, based on dzndz1 value. If reached, the loop is exited with exit code “stationnary”

calc_d2zndc2:

If True, activates the additional computation of d2zndc2, needed only for the alternative normal map shading ‘Milnor’.

calc_orbit: bool

If True, stores the value of an orbit point @ exit - orbit_shift

backshift: int (> 0)

The number of iteration backward for the stored orbit starting point

Notes

The following complex fields will be calculated: zn and its derivatives (dzndc, d2zndc2*[optionnal], *dzndz [optionnal]). If calc_orbit is activated, zn_orbit will also be stored Exit codes are 0: max_iter, 1: divergence, 2: stationnary.

newton_calc(*, calc_name: str = 'newton_calc', subset: Fractal_array | None = None, known_orders: int | None = None, max_order: int = 500, max_newton: int = 20, eps_newton_cv: float = 1e-12)[source]

Newton iterations for Mandelbrot standard set interior (power 2).

Parameters:
calc_namestr

The string identifier for this calculation

subsetOptional fractalshades.postproc.Fractal_array

A boolean array-like, where False no calculation is performed If None, all points are calculated. Defaults to None.

known_ordersNone | int list

If not None, only the integer listed of their multiples will be candidates for the cycle order, the other rwill be disregarded. If None all order between 1 and max_order will be considered.

max_orderint

The maximum value tested for cycle order

eps_newton_cvfloat

A small float to qualify the convergence of the Newton iteration Usually a fraction of a view pixel.

Notes

Note

The following complex fields will be calculated:

zr

A (any) point belonging to the attracting cycle

attractivity

The cycle attractivity (for a convergent cycle it is a complex of norm < 1.)

dzrdc

Derivative of zr

dattrdc

Derivative of attractivity

The following integer field will be calculated:

order

The cycle order

Exit codes are 0: max_order, 1: order_confirmed.

References

class fractalshades.models.Mandelbrot_N(directory: str, exponent: int)[source]
__init__(directory: str, exponent: int)[source]

A standard power-N Mandelbrot Fractal set implementation.

\[\begin{split}z_0 &= 0 \\ z_{n+1} &= {z_{n}}^N + c\end{split}\]
Parameters:
directorystr

Path for the working base directory

calc_std_div(*, calc_name: str, subset: Fractal_array | None = None, max_iter: int, M_divergence: float, epsilon_stationnary: float, calc_d2zndc2: bool = False, calc_orbit: bool = False, backshift: int = 0)[source]

Basic iterations for the Mandelbrot standard set (power n).

Parameters:
calc_namestr

The string identifier for this calculation

subsetOptional fractalshades.postproc.Fractal_array

A boolean array-like, where False no calculation is performed If None, all points are calculated. Defaults to None.

max_iterint

the maximum iteration number. If reached, the loop is exited with exit code “max_iter”.

M_divergencefloat

The diverging radius. If reached, the loop is exited with exit code “divergence”

epsilon_stationnaryfloat

A small float to early exit non-divergent cycles (based on cumulated dzndz product). If reached, the loop is exited with exit code “stationnary” (Those points should belong to Mandelbrot set interior). A typical value is 1.e-3

calc_d2zndc2: bool

If True, activates the additional computation of d2zndz2, needed only for the alternative normal map shading ‘Milnor’.

calc_orbit: bool

If True, stores the value of an orbit point @ n of exit - backshift

backshift: (> 0)

The number of iteration backward for the stored orbit starting point

Notes

The following complex fields will be calculated: zn and its derivatives (dzndz, dzndc). If calc_orbit is activated, zn_orbit will also be stored Exit codes are max_iter, divergence, stationnary.

newton_calc(*, calc_name: str = 'newton_calc', subset: Fractal_array | None = None, known_orders: int | None = None, max_order: int = 500, max_newton: int = 20, eps_newton_cv: float = 1e-12)[source]

Newton iterations for Mandelbrot standard set interior (power N).

Parameters:
calc_namestr

The string identifier for this calculation

subsetOptional fractalshades.postproc.Fractal_array

A boolean array-like, where False no calculation is performed If None, all points are calculated. Defaults to None.

known_ordersNone | int list

If not None, only the integer listed of their multiples will be candidates for the cycle order, the other rwill be disregarded. If None all order between 1 and max_order will be considered.

max_orderint

The maximum value tested for cycle order

eps_newton_cvfloat

A small float to qualify the convergence of the Newton iteration Usually a fraction of a view pixel.

Notes

Note

The following complex fields will be calculated:

zr

A (any) point belonging to the attracting cycle

attractivity

The cycle attractivity (for a convergent cycle it is a complex of norm < 1.)

dzrdc

Derivative of zr

dattrdc

Derivative of attractivity

The following integer field will be calculated:

order

The cycle order

Exit codes are 0: max_order, 1: order_confirmed.

References

class fractalshades.models.Burning_ship(directory: str, flavor: ~typing.Literal[<enum 'BS_flavor_enum'>] = 'Burning ship')[source]
__init__(directory: str, flavor: ~typing.Literal[<enum 'BS_flavor_enum'>] = 'Burning ship')[source]

A Burning Ship Fractal (power 2). The basic equation a detailed below:

\[\begin{split}x_0 &= 0 \\ y_0 &= 0 \\ x_{n+1} &= x_n^2 - y_n^2 + a \\ y_{n+1} &= 2 |x_n y_n| - b\end{split}\]

where:

\[\begin{split}z_n &= x_n + i y_n \\ c &= a + i b\end{split}\]
Parameters:
directorystr

Path for the working base directory

flavorstr

The variant of Burning Ship detailed implementation, defaults to “Burning Ship”. Acceptable values are listed below in notes.

Notes

Note

Several variants (flavor parameter) are implemented with the following iteration formula:

  • “Perpendicular burning ship” variant of the Burning Ship Fractal.

    \[\begin{split}x_{n+1} &= x_n^2 - y_n^2 + a \\ y_{n+1} &= 2 x_n |y_n| - b\end{split}\]
  • “Shark fin” variant

    \[\begin{split}x_{n+1} &= x_n^2 - y_n |y_n| + a \\ y_{n+1} &= 2 x_n y_n - b\end{split}\]
  • “Celtic” variant

    \[\begin{split}x_{n+1} &= |x_n^2 - y_n^2| + a \\ y_{n+1} &= 2 x_n y_n - b\end{split}\]
  • “Buffalo” variant

    \[\begin{split}x_{n+1} &= |x_n^2 - y_n^2| + a \\ y_{n+1} &= 2 |x_n y_n| - b\end{split}\]
calc_std_div(*, calc_name: str, subset, max_iter: int, M_divergence: float, calc_orbit: bool = False, backshift: int = 0)[source]

Basic iterations for Burning ship set.

Parameters:
calc_namestr

The string identifier for this calculation

subsetfractalshades.postproc.Fractal_array

A boolean array-like, where False no calculation is performed If None, all points are calculated. Defaults to None.

max_iterint

the maximum iteration number. If reached, the loop is exited with exit code “max_iter”.

M_divergencefloat

The diverging radius. If reached, the loop is exited with exit code “divergence”

calc_orbit: bool

If True, stores the value of an orbit point @ exit - orbit_shift

backshift: int (> 0)

The count of iterations backward for the stored orbit starting point

Notes

The following complex fields will be calculated: xn yn and its derivatives (dxnda, dxndb, dynda, dyndb). If calc_orbit is activated, zn_orbit will also be stored Exit codes are max_iter, divergence.

class fractalshades.models.Power_tower(directory)[source]
__init__(directory)[source]

The tetration fractal - standard precision implementation

\[\begin{split}z_0 &= 1 \\ z_{n+1} &= c^{z_n} \\ &= \exp(z_n \log(c))\end{split}\]

This class implements limit cycle calculation through Newton search

Parameters:
directorystr

Path for the working base directory

newton_calc(*, calc_name: str, subset=None, compute_order=True, max_order, max_newton, eps_newton_cv)[source]

Newton iterations for the tetration fractal

Parameters:
calc_namestr

The string identifier for this calculation

subset

A boolean array-like, where False no calculation is performed If None, all points are calculated. Defaults to None.

compute_orderbool

If True, the period of the limit cycle will be computed If None all order between 1 and max_order will be considered.

max_orderint

The maximum value for cycle order

eps_newton_cvfloat

A small float to qualify the convergence of the Newton iteration Usually a fraction of a view pixel.

Notes

Note

The following complex fields will be calculated:

zr

A (any) point belonging to the attracting cycle

dzrdz

The cycle attractivity (for a convergent cycle it is a complex of norm < 1.)

The following integer field will be calculated:

order

The cycle order

Exit codes are max_order, order_confirmed.

class fractalshades.models.Collatz(directory)[source]
__init__(directory)[source]

The Collatz fracal:

\[\begin{split}z_0 &= c \\ z_{n+1} &= 0.25 (2 + 7 z_n - (2+5z_n) \cos(\pi z_n))\end{split}\]

This fractal is linked to the Syracuse conjecture.

Parameters:
directorystr

Path for the working base directory

base_calc(*, calc_name: str, subset, max_iter: int, M_divergence: float, epsilon_stationnary: float)[source]

Basic iterations for Mandelbrot standard set (power 2).

Parameters:
calc_namestr

The string identifier for this calculation

subsetfractalshades.postproc.Fractal_array

A boolean array-like, where False no calculation is performed If None, all points are calculated. Defaults to None.

max_iterint

the maximum iteration number. If reached, the loop is exited with exit code “max_iter”.

M_divergencefloat

The diverging radius. If reached, the loop is exited with exit code “divergence”

epsilon_stationnaryfloat

A small float to early exit non-divergent cycles (based on cumulated dzndz product). If reached, the loop is exited with exit code “stationnary” (Those points should belong to Mandelbrot set interior). A typical value is 1.e-3

Notes

The following complex fields will be calculated: zn and its derivatives (dzndz, dzndc, d2zndc2). Exit codes are max_iter, divergence, stationnary.