{'fraction_non_alphanumeric': 0.042176364216572705, 'fraction_numerical': 0.01616849271354111, 'mean_word_length': 4.501170275014628, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Computing complex horseshoes by means of piecewise maps

A systematic procedure to numerically compute a horseshoe map is presented. This new method uses piecewise functions and expresses the required operations by means of elementary transformations, such as translations, scalings, projections and rotations. By repeatedly combining such transformations, arbitrarily complex folding structures can be created. We show the potential of these horseshoe piecewise maps to illustrate several central concepts of nonlinear dynamical systems, as for example the Wada property.


Introduction
The Smale horseshoe map is one of the hallmarks of chaos. It was devised in the 1960's by Stephen Smale [Smale, 1967] to reproduce the dynamics of a chaotic flow in the neighborhood of a given periodic orbit. It describes in the simplest way the dynamics of homoclinic tangles, which were encountered by Henri Poincaré [Poincaré, 1890] and were intensively studied by George Birkhoff [Birkhoff, 1927], and later on by Mary Catwright and John Littlewood, among others [Catwright & Littlewood, 1945, 1947Levinson, 1949].
The horseshoe map is commonly represented starting with a set with the shape of a stadium. This set is flattened along its shortest side and stretched along the orthogonal direction, which corresponds to the largest side of the stadium. Finally, the resulting set is folded acquiring the shape of a horseshoe and embedded in the original set. A two-dimensional fixed point theorem demonstrates that every continuous map defined on the plane, which iterates some set transversally to itself, contains a fixed point [Alligood et al., 1996]. Since the horseshoe has two legs, there must be at least two fixed points in the original domain (see Figs. 1(a) and (b)). These two fixed points are saddles, whose invariant manifolds take after the iterations of the horseshoe, as shown in Fig. 1(c). A third fixed point outside the region defined by the three vertical strips represents an attractor, as depicted in red color in Fig. 1(a). All the initial conditions belonging to the stadium, except for an invariant set of zero Lesbesgue measure, end up in such attractor. The colors match the initial set and the images through the map. Two saddle fixed points are shown in yellow. (c) The invariant manifolds associated with one of the saddles shown before. In blue, a transverse homoclinic intersection between the stable and the unstable manifolds.
The dynamics of the horseshoe map has been widely studied using Markov partitions and symbolic dynamics [Adler, 1998;Devaney, 1989]. Also simpler discontinuous maps, as for example the baker map [Halmos, 2017], can be devised, which allow to easily compute their Lyapunov exponents in order to prove the existence of chaotic trajectories [Alligood et al., 1996]. Nevertheless, as far as we are concerned, a set of equations that permit to compute a continuous map that represents a horseshoe with any desired number of foldings is still missing. The relevance of such a mapping lies in the fact that it can be used to study properties of chaotic dynamical systems and, perhaps more importantly nowadays, to develop or simplify control methods based on the dynamics of the horseshoe [Zambrano et al., 2008].
In the present work we introduce a mechanistic procedure to construct two-dimensional continuous mappings that allow to numerically compute horseshoes with any desired number of foldings. The paper is organized as follows. In Sec. 2 we describe four two-dimensional continuous maps, which can be composed to obtain the Smale horseshoe map. In Sec. 3 we present an example that shows how to extend the map to represent more complicated horseshoes, with more than one folding. Finally, in Sec. 4 we present several applications of these new piecewise mappings.

Flatten, stretch and fold
A hyperbolic chaotic flow consists in an unstable and bounded motion, for which it is necessary that some directions in phase space are locally expansive (unstable) and some others are contractive (stable). In particular, if an ensemble of initial conditions in phase space is considered, after a very short time, this set will have expanded along some directions and contracted along some others. For simplicity, suppose that the dynamical system is three-dimensional and that a Poincaré map can be constructed at the plane z = 0. As shown in Fig. 2(a), we begin with a square Q ⊂ R 2 as the initial set. Then, suppose that a forward iteration of the map expands this set linearly and homogeneously in the direction of the x-axis by some amount and contracts it in the other direction y in a similar way. Obviously, we obtain as a result a rectangle, as depicted in Fig 2(b). If we carry out this linear transformation repeatedly, we would asymptotically obtain an unbounded set in the direction of the x-axis, isomorphic to the real line. Therefore, if we want to keep the evolving set bounded, we need to provide a mechanism to bend the set against the expanding direction. It is precisely the nonlinearity that introduces the curvature required for the bending, maintaining the dynamics trapped in some region of phase space. This requirement is essential, since linear transformations always transform parallel lines into parallel lines. In summary, a continuous chaotic dynamical system requires at least three ingredients: a contraction and a stretch (saddles), which can be carried out by simple linear transformations, and a folding, for which a nonlinear transformation is necessary.
Based on these ideas, we can build a horseshoe in a very simple manner by a composition of elementary transformations. We follow the steps represented in Fig. 2. First of all, we start with the unit square Q = [0, 1] × [0, 1] and carry out the flattening and the stretching shown in Fig. 2(b), by means of the function H 1 (x, y), which is defined as follows Note that the stretching only applies in the region 0 ≤ x ≤ 1 and that we have added a translation for x > 1. The reason for such restriction is that we want to keep the shape of the blue folding, which lies out of the unit square after the first iteration (see Fig. 2(e)), when we apply the second iteration of the map. In this manner, we avoid its expansion along the x-axis. Instead of stretching it, we simply translate it in such a way that, when computing the second iteration of the map, it is placed at the end of the flattened and stretched green rectangle appearing in Fig. 2(c).
Secondly, we perform a translation over the whole set, as depicted in Fig. 2(c), lifting up the whole thin rectangle and moving it to the left, so that it lies slightly above the x-axis and runs through the y-axis. This affine transformation can be written as (2) Now it comes the most difficult part, which is the folding shown in Figs. 2(d) and (e). We perform it separately in two steps, one related to the red set, and another for the blue one. Firstly, we apply a translation T (a) to the red rectangle appearing in Fig. 2(d) to place it at the origin, where a represents the vector along which the translation is carried out. Then, we apply the counterclockwise rotation R(θ) by an angle θ = π radians to the rectangle. Finally, we perform one more translation T (b) of the rectangle by means of the vector b, so that it lies symmetrical to the other light red rectangle (see Fig. 2(e)) with respect to the line y = 1/2. These operations can be written as where the vector parameters a = (−13/5, −1/4) and b = (2/5, 3/4) have been chosen, in accordance with previous parameter values appearing in the transformation H 1 . The whole transformation is shown in Fig. 3. Then, we proceed with the blue region, which is more complicated than the red, since it corresponds to the nonlinear folding. We start by applying a translation T (c) to the blue rectangle shown in Fig. 4(a) along the direction defined by the vector c. Then, we project the rectangle on the y-axis by means of the operator Π y , which corresponds to a projector defined as Such projection is shown in Fig. 4(b). Finally, we have to perform a rotation R(θ) of an angle θ depending on the position on the x-axis, so that the thin vertical yellow strip appearing in Fig. 4(b) and Fig. 4(c) does not rotate, the green vertical strip rotates π/2 radians and the red one rotates π radians. This can be achieved by a linear dependence between the angle and the x coordinate in the form θ(x) = πx. With this linear dependence of the angle with the coordinate x, the rotation R(θ(x)) becomes nonlinear. Finally, and as shown in Fig. 3(d), we perform the translation T −1 (c) to place the folded part back in its original place. In summary, the whole transformation is T −1 (c)R(θ(T (c)x))Π y T (c)x and, in matrix form, it explicitly reads where c = (−1, −1/2), as shown in Fig. 3(a). The map that performs all these algebraic operations can be written as  (x, y) for x ≤ 1 (y − 1/2)(− sin(π(x − 1)), cos(π(x − 1))) + (1, 1/2) for 1 < x < 2 −((x, y) − (13/5, 1/4)) + (2/5, 3/4) for x ≥ 2 .
Finally, for aesthetic purposes, to keep the shape of the regions in the negative part of the x-axis unaltered, we perform a contraction of the same size that the one performed in the first contraction in the y-axis, but now for negative values of the x-axis. Therefore, this fourth transformation reads The horseshoe map is simply the composition of these four transformations H = H 4 • H 3 • H 2 • H 1 . We recall that this map H is continuous and one-to-one, but not differentiable, since H 3 is not differentiable at the points (1, y) and (2, y), which are the points delimiting the folded rectangle. This lack of smoothness contrasts with the original horseshoe conceived by Stephen Smale [Smale, 1967]. In Fig. 5 we take the unit square and iterate it under the map H, showing its successive iterations. Even though the equations of the map (Eq. (1) and Eq. (6)) look cumbersome, their interpretation in terms of elementary linear transformations and their numerical programming are rather simple. This fact has the advantage of allowing us to develop more sophisticated horseshoes in the following sections.
As we have designed it, the map contracts the area of the original unit square, since the contraction defined in H 1 is more pronounced than the stretching appearing in the same transformation. Moreover, the folding appearing in Fig. 4

Horseshoes with more than one folding
Following the same recipe, we can construct more sophisticated schemes with an arbitrary number of foldings. For instance, a double horseshoe has been proposed to explain the fractal basin boundaries separating two attractors [McDonald et al., 1985;Aguirre et al., 2009]. This situation, also associated with transient chaotic dynamics, can be reproduced following the same procedure used in the previous section. A possible map capable of representing fractal basin boundaries results from the composition of the four following piecewise maps G 2 (x, y) = (x, y) + (−1/5, 1/10), (x, y) for x ≤ 1 (y − 7/20)(− sin(π(x − 1)), cos(π(x − 1))) + (1, 7/20) for 1 < x ≤ 2 −((x, y) − (5/2, 1/5)) + (1/2, 5/10) for 2 < x ≤ 3 (y − 7/20)(sin(π(x − 3)), cos(π(x − 3))) We represent the iterations of the unit square under the map Fig. 6. Two new elementary transformations appear in G 3 , which has an additional clockwise rotation for the new blue folding and also one more translation for the upper red rectangle appearing in Fig. 6(a). Now there are two stable fixed points out of the unit square, one for positive values of x in the upper part, and another for negative values of x, in the lower part. As we show in the next section, the stable manifold of a saddle fixed point in the unit square separates the basin boundaries of these two attractors, whose boundary is fractal.
We note that, for a horseshoe with a single folding, the number of attractors outside Q is one, while in this case there are two. In fact, the same holds if the number of foldings is even, while there is only one attractor if the number of foldings is odd. Therefore, the coexistence of more than two attractors requires more than one folding horseshoe.

Applications
Since chaos is related to the existence of horseshoes, the practical use of these piecewise maps is to investigate properties of chaotic dynamical systems. In the following lines we introduce several applications of these horseshoe maps, to illustrate how they can be used with different purposes. After examining two well-known examples, and as a completely new feature, we show that a three-fold horseshoe can give rise to basin boundaries exhibiting the so-called Wada property [Yoneyama , 1917]. Given the fact that homoclinic tangles give rise to infinitely many successive foldings, this fact explains why the Wada property appears so frequently in nonlinear multistable dynamical systems [Aguirre et al., 2009;Vandermeer , 2004;Portela et al., 2007;Toroczkai et al., 1997;Daza et al., 2017] and dispersive systems with several escapes [Poon et al., 1996;Sweet et al., 1999;Seoane & Sanjuán , 2012]. Finally, we show how one-dimensional unimodal or multimodal maps can be in general computed from horseshoes with one or more foldings, which can simplify enormously the manipulation of a dynamical system.

Basins of attraction
As shown in the previous section, the scheme proposed in [McDonald et al., 1985] to demonstrate that horseshoes are responsible for the fractal nature of the boundary of the basins of attraction separating coexisting attractors, can be directly tested using these maps. We recall that a basin of attraction is the set of all the points that end in a particular attractor. In Fig. 7(a) we represent the basins of attraction of the two attractors x * 1 = (−0.05, 0.125) and x * 2 = (1.05, 0.875) that lie outside the unit square given by the map G described in the previous section. Their boundary consists of vertical lines, associated to the stable manifold of a saddle fixed point in the unit square Q. Successive magnifications of the basins are shown in Figs. 7(b-d), which clearly suggest their fractal nature.

Chaotic saddle
Another important invariant set associated to transient chaotic dynamics is the non-attracting invariant set, also called the chaotic saddle. This set is formed by all the points in the unit square that do not escape to the attractor by forward or backward iteration. It can be computed by means of the Sprinkler Algorithm [Hsu et al., 1998], as shown in Fig. 8. If we look at Fig. 5(d), the chaotic saddle can be iteratively computed as the intersection H n (Q) ∩ H −n (H n (Q) ∩ Q) when n tends to infinity and with Q the unit square. For instance, the first iteration is the intersection of the green vertical and red horizontal strips in Fig. 5(a), which consists of four squares.

Basins of Wada
Even though it is not possible to have more than two attractors outside the unit square with a horseshoe map, we can create systems with more than two escapes from the unit square and study the escape basins. In fact, using a minimum number of three foldings, it is possible to create an escape basin with the Wada property. Three basins possess this property if every point of the boundary of a particular basin belongs to the boundary of the remaining two basins [Kennedy & Yorke , 1991;Nusse & Yorke , 1996].
A three-fold horseshoe map is shown in Fig. 9(a). The equations that describe this map are a straightforward extension of the equations shown in the previous section and we omit them because they are quite long. The escape basins can be defined, relating a different escape to each of the three foldings appearing in Fig. 9(a). The associated basin appearing in Fig. 9(b) is a basin of Wada, as can be demonstrated using recent numerical techniques [Daza et al., 2015[Daza et al., , 2018.

Multimodal 1D maps
We conclude the present work by demonstrating that a horseshoe with multiple foldings yields a multimodal map, by simply projecting its boundary along the stretching direction. The relevance of this correspondence is that it allows to reduce the dimensionality of a dynamical system, which simplifies enormously its study. To the best of our knowledge, this fact appears sometimes in the literature, but without a detailed explanation of how these two maps are connected [Nicolis, 1995]. As shown in Fig. 10(a), if we care about the lower edge I = [0, 1] of the unit square Q only, we see that after one iteration H(I) this set corresponds to the external boundary of the horseshoe. If we now project such external boundary on the x-axis by means of a projector Π x , we obtain a unimodal map. In other words, the restriction of the horseshoe to the stretching axis (the x-axis in our examples) yields a unimodal one-dimensional map. As shown in Fig. 10(b), this fact is immediately verified using our piecewise maps. The present argument can be extended in a very simple way to show that a horseshoe with several foldings can be related to a multimodal map.

Conclusions and Discussion
We have provided a systematic procedure to compute complex folding structures. This is achieved by using two-dimensional piecewise maps, which accomplish all the required elementary transformations, such as translations, projections, scalings and rotations, both linear and nonlinear. These mathematical functions can be useful to investigate central properties of chaotic dynamical systems and, from the point of view of computational running times, they are very affordable. A particularly interesting application has been presented, which consists on the simplest twodimensional dynamical system that presents the Wada property. As we have shown, more than two escape basins can share their whole boundary if horseshoes with more than two foldings are present in the system. In particular, a folding structure with three foldings is sufficient for a dynamical system to display such property. Another application of these maps is the illustration of how multimodal maps can be derived from horseshoe maps with several foldings. Despite its simplicity, this equivalence is of paramount importance. Methods to obtain a Smale horseshoe in an arbitrary low-dimensional chaotic dynamical system have been developed recently [Li & Yang , 2010;Li et al., 2012]. Therefore, this correspondence allows us to reduce the dimensionality of the dynamical system even further, and also to apply our vast knowledge on unidimensional maps [May, 1976;Sharkovsky , 2013;Collet & Eckmann , 1980] to a wide spectrum of dynamical systems. As it has been recently shown, this capacity to reduce the dimensionality of the dynamical system can also entail a considerable simplification of some control methods, as for example the partial control method [Capeans et al., 2017].