Another essay. This time let's play with complex numbers, with formulas and their visualization.
Idea
A complex number is a certain extension of a real number, in fact a vector for which a whole set of axioms is defined. Any complex (and hence real) number can be written as , where a is the real part, b is the imaginary part, i is the root of the equation . For him, many operations are defined that are defined for a real number, for example, . Interestingly, if you do various operations with them, raise to a power, multiply, etc., and then take (real part) for the axis Ox, and (imaginary part) for the Oy axis, you can get funny pictures.
By the way, I myself came up with all the following formulas.
Visualization function
Routine. The function, which according to this iterative function draws everything on the field:
import random import numpy as np defvis(A, f, step=1.0, c=None): x = [] y = [] for B in np.arange(0, A, step): v = f(A, B) x.append(v.real) y.append(v.imag) plt.figure(figsize=[8, 8]) mxabs = max([i[0] ** 2 + i[1] ** 2for i in zip(x, y)]) ** 0.5 x = np.array(x) / mxabs y = np.array(y) / mxabs if c isNone: plt.scatter(x, y) else: plt.scatter(x, y, color=[c(x[i], y[i]) for i in range(len(x))]) plt.show()
All our functions depend on two parameters A and B. Moreover, we iterate over B inside vis (), and A is the global parameter of the function.
Note that these numbers do not follow from the calculation of any definite integral on a smooth manifold and other smart words meaningless in this context. These are really random numbers, and there is still exactly infinity of different A, as a result of which beauty is obtained.
Need to paint
We declare a color function (such a function that returns a tuple of three numbers in coordinates):