fractals.julia_sets =================== .. py:module:: fractals.julia_sets .. autoapi-nested-parse:: Author Alexandre De Zotti Draws Julia sets of quadratic polynomials and exponential maps. More specifically, this iterates the function a fixed number of times then plots whether the absolute value of the last iterate is greater than a fixed threshold (named "escape radius"). For the exponential map this is not really an escape radius but rather a convenient way to approximate the Julia set with bounded orbits. The examples presented here are: - The Cauliflower Julia set, see e.g. https://en.wikipedia.org/wiki/File:Julia_z2%2B0,25.png - Other examples from https://en.wikipedia.org/wiki/Julia_set - An exponential map Julia set, ambiantly homeomorphic to the examples in https://www.math.univ-toulouse.fr/~cheritat/GalII/galery.html and https://ddd.uab.cat/pub/pubmat/02141493v43n1/02141493v43n1p27.pdf Remark: Some overflow runtime warnings are suppressed. This is because of the way the iteration loop is implemented, using numpy's efficient computations. Overflows and infinites are replaced after each step by a large number. Attributes ---------- .. autoapisummary:: fractals.julia_sets.c_cauliflower fractals.julia_sets.c_exponential fractals.julia_sets.c_polynomial_1 fractals.julia_sets.c_polynomial_2 fractals.julia_sets.nb_iterations fractals.julia_sets.nb_pixels fractals.julia_sets.window_size fractals.julia_sets.z_0 Functions --------- .. autoapisummary:: fractals.julia_sets.eval_exponential fractals.julia_sets.eval_quadratic_polynomial fractals.julia_sets.ignore_overflow_warnings fractals.julia_sets.iterate_function fractals.julia_sets.prepare_grid fractals.julia_sets.show_results Module Contents --------------- .. py:function:: eval_exponential(c_parameter: complex, z_values: numpy.ndarray) -> numpy.ndarray Evaluate $e^z + c$. >>> float(eval_exponential(0, 0)) 1.0 >>> bool(abs(eval_exponential(1, np.pi*1.j)) < 1e-15) True >>> bool(abs(eval_exponential(1.j, 0)-1-1.j) < 1e-15) True .. py:function:: eval_quadratic_polynomial(c_parameter: complex, z_values: numpy.ndarray) -> numpy.ndarray >>> eval_quadratic_polynomial(0, 2) 4 >>> eval_quadratic_polynomial(-1, 1) 0 >>> round(eval_quadratic_polynomial(1.j, 0).imag) 1 >>> round(eval_quadratic_polynomial(1.j, 0).real) 0 .. py:function:: ignore_overflow_warnings() -> None Ignore some overflow and invalid value warnings. >>> ignore_overflow_warnings() .. py:function:: iterate_function(eval_function: collections.abc.Callable[[Any, numpy.ndarray], numpy.ndarray], function_params: Any, nb_iterations: int, z_0: numpy.ndarray, infinity: float | None = None) -> numpy.ndarray Iterate the function "eval_function" exactly nb_iterations times. The first argument of the function is a parameter which is contained in function_params. The variable z_0 is an array that contains the initial values to iterate from. This function returns the final iterates. >>> iterate_function(eval_quadratic_polynomial, 0, 3, np.array([0,1,2])).shape (3,) >>> complex(np.round(iterate_function(eval_quadratic_polynomial, ... 0, ... 3, ... np.array([0,1,2]))[0])) 0j >>> complex(np.round(iterate_function(eval_quadratic_polynomial, ... 0, ... 3, ... np.array([0,1,2]))[1])) (1+0j) >>> complex(np.round(iterate_function(eval_quadratic_polynomial, ... 0, ... 3, ... np.array([0,1,2]))[2])) (256+0j) .. py:function:: prepare_grid(window_size: float, nb_pixels: int) -> numpy.ndarray Create a grid of complex values of size nb_pixels*nb_pixels with real and imaginary parts ranging from -window_size to window_size (inclusive). Returns a numpy array. >>> prepare_grid(1,3) array([[-1.-1.j, -1.+0.j, -1.+1.j], [ 0.-1.j, 0.+0.j, 0.+1.j], [ 1.-1.j, 1.+0.j, 1.+1.j]]) .. py:function:: show_results(function_label: str, function_params: Any, escape_radius: float, z_final: numpy.ndarray) -> None Plots of whether the absolute value of z_final is greater than the value of escape_radius. Adds the function_label and function_params to the title. >>> show_results('80', 0, 1, np.array([[0,1,.5],[.4,2,1.1],[.2,1,1.3]])) .. py:data:: c_cauliflower :value: (0.25+0j) .. py:data:: c_exponential :value: -2.0 .. py:data:: c_polynomial_1 :value: (-0.4+0.6j) .. py:data:: c_polynomial_2 :value: (-0.1+0.651j) .. py:data:: nb_iterations :value: 56 .. py:data:: nb_pixels :value: 666 .. py:data:: window_size :value: 2.0 .. py:data:: z_0