{'fraction_non_alphanumeric': 0.041463296767022664, 'fraction_numerical': 0.020586671821388874, 'mean_word_length': 4.14648097488187, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Drawing butterflies from the almost Mathieu operator

Plotting spectra of a range of almost Mathieu operators reveals a beautiful fractal-like image that contains multiple copies of a butterfly image. We demonstrate that plotting the butterflies using a gap-labelling scheme based on K-theory or Chern numbers reveals systematic discontinuities in the gap positioning. A proper image is produced only when we take into account these discontinuities, and close the butterfly wingtips at the points of discontinuity. A conjecture is presented showing a simple formula for locating the discontinuities, and numerical evidence is given to support the conjecture. We also present new renderings of this butterfly.


Introduction
The inspiration for this work is the diagram in Figure 1, a fractal-like structure known as the Hofstadter butterfly (Hofstadter, 1976), which represents the energy levels of an electron travelling through a periodic lattice under the influence of a magnetic field; that is, a Bloch electron (Brown, 1964). Each horizontal line in the image corresponds to union of spectra of certain bounded self-adjoint operators H θ,φ on the Hilbert space l 2 (Z), defined by the equation (H θ,φ x) n = x n−1 + x n+1 + 2 cos(2πnθ + φ)x n , where the parameter θ ∈ [0, 1] corresponds to the vertical position in the image in Figure 1, and φ is a physical phase parameter. This operator, known as the almost Mathieu operator and also as Harper's operator (Last, 1994), is a discrete, one-dimensional Schrödinger operator, which has been the object of study for many important physical problems (Goldman, 2009).
Equivalently, each horizontal line in Figure 1 represents the spectrum of the selfadjoint operator h θ = u + u * + v + v * where unitaries u, v are generators of the rotation C*-algebra A θ , characterized by a commutation rule vu = e 2πiθ uv. These particular algebras are known as non-commutative tori and are of considerable interest in noncommutative geometry (Connes, 1994). The Cantor-like structure of the spectra for operators in these algebras has been a topic of study in C*-algebras for quite some time, as discussed in (Avila and Jitomirskaya, 2006;Bellissard and Simon, 1982;Choi et al., 1990;Last, 1994;Puig, 2004) Figure 2. Drawing only the butterflies.
Our interest in this paper is in the mechanics of drawing the image in Figure 1, its related image in Figure 2, and what this reveals about gap labelling theorems (Bellissard, 1990;Goldman, 2009;Kaminker and Putnam, 2003;Ypma, 2007) for these Schrödinger operators. This particular image in Figure 1 was created in high resolution, using the numerical package MATLAB (TheMathWorks, 2008) to accurately compute the eigenvalues of certain tridiagonal matrices, then plotting line segments between eigenvalues using PostScript commands to ensure a high quality image. It is useful to refer to (Casselman, 2005) for details on how to create such high resolution mathematical illustrations in PostScript.
In the finely rendered image in Figure 1, the viewer's eye is immediately drawn to butterfly-like structures in the diagram which repeat over and over at various scales and positions. Following Casselman's dictum that mathematical drawings should represent concepts, not accidents (Casselman, 2005), it is fascinating to consider how we might draw only the butterflies. In Figure 2, we do exactly that, drawing precisely the butterflies that are inherent in the image in Figure 1, without drawing all the spectral lines themselves.
This new high resolution image was also created using Postscript commands, based on numerical calculations of spectra of operators generated in MATLAB. This new image highlights the fractal symmetry of the diagram and suggests further investigation on the explicit symmetries.
The goal of this paper is to record the algorithmic process used to image only the butterflies, using the gap labelling procedure for the almost Mathieu operator. We discover through this process that, from a certain point of view, there are discontinuities in gap labelling, and we present a conjecture for specifying where these discontinuities occur. It appears this conjecture is new to the literature, but we are at a loss to prove it. The conjecture is verified for low rational values of parameter θ.
A secondary goal is to reveal this new approach to rendering a high resolution image of the Hofstadter butterfly.

Spectral calculations
The spectral calculations for h θ are well-known, and are particularly straightforward when θ is rational (Choi et al., 1990;Lamoureux and Mingo, 2007). For θ = p/q in reduced form, irreducible representations of the rotation C*-algebra A θ are obtained using q × q matrices U, V , with U a cyclic permutation matrix and V a diagonal matrix with entries given as consecutive integer powers of e 2πip/q . Under the irreducible representation, the operator h θ maps to the q × q matrix where z 1 , z 2 are complex numbers of modulus one, specifying the different irreducible representations. The spectrum of h θ is just the union of the point spectra for the various matrices H θ,z 1 ,z 2 over the range of z 1 , z 2 The characteristic polynomial of the q ×q matrix H θ,z 1 ,z 2 is invariant under changes of parameters z 1 , z 2 , except for a zero-order term z q 1 + z −q 1 + z q 2 + z −q 2 . Consequently, the union of spectra over the set of parameters z 1 , z 2 is just the inverse image, under a degree q polynomial, of the range of values for the term z q 1 + z −q 1 + z q 2 + z −q 2 . This range is the interval [−4, 4], and the inverse image is a set of q distinct intervals on the real line.
These q intervals are all disjoint, except in the case q even, in which case the central two intervals just touch at the spectral point zero. Thus, there are precisely q − 1 gaps between intervals in the spectrum of h θ , where we include the "empty gap" at spectral value zero, for convenience.
To compute the spectral intervals, it suffices to compute the endpoints of each interval and then connect with a line. The endpoints of the interval are obtained by choosing values of z 1 , z 2 such that the constant term z q 1 + z −q 1 + z q 2 + z −q 2 obtains its extreme values ±4.
The q × q matrix H θ,z 1 ,z 2 is almost tridiagonal -and by choosing the extreme values for z 1 , z 2 , we can apply explicit Givens rotations to obtain a preferential tridiagonal form for H θ,z 1 ,z 2 , as described in (Lamoureux, 1997). In fact, the matrix then decomposes as the direct sum of two tridiagonal matrices, each of size approximately q/2×q/2. Finding eigenvalues for these tridiagonal matrices is an order q 2 operation, which is a fast computation in this application.
3. Gap labelling: inverse slope 1, -1 To draw the butterfly wings, we do not draw the spectral lines, but instead draw curves around the spectral gaps.
The spectral gaps are conveniently labelled using a Diophantine equation, where integer parameters t, s are fixed, and we select the r-th gap in spectrum θ = p/q using the formula This indexing is known as gap labelling, as described in (Bellissard, 1990;Goldman, 2009;Kaminker and Putnam, 2003;Ypma, 2007), and the parameters (t, s) are related to indices in K-theory, or equivalently, Chern numbers. Here, the point is that at each spectral level θ = p/q, the r-th gap does actually appear (if we also include the zero-length gap at spectral value 0), and we have a convenient way of marching through all the gaps.
Of course one must choose reasonable values of t, s in order to give a reasonable r value in the range of 1 . . . q − 1, since there are only q − 1 gaps. Thus for integers t > 0 we require 0 ≤ s ≤ t − 1 and for t < 0 we require t ≤ s ≤ −1.
Note we are using a slightly different convention from the literature for our gap labelling, introducing a minus sign into the Diophantine equation This allows us to keep indices (t, s) with the same sign, which is just a matter of convenience in our algorithm.
As an example, we set t = 1 which forces s = 0, and we plot the gaps in first image shown in Figure 3. There are two curves in this first image. First, the curve on the left of the butterfly wing, which consists of the right endpoints of spectral intervals to the left of the gap. Second, the curve on the right of the butterfly, consisting of the left endpoints of the spectral intervals to the right of the gap.
For the negative slope t = −1, we are forced to take s = −1, and we see the plot for the downward sloping butterfly wings, also shown in Figure 3.  It is useful to refer to the parameter t as the inverse slope, for the Diophantine equation r = t * p − s * q becomes, after division by q, a linear equation where t indicates the slope between variables x and θ. Notice something special happens at the wingtips, where θ = 0, 1. For these values of θ, there is no spectral gap, as the spectrum consists of the single interval [−4, 4]. So it does not make sense to identify the r-th gap there. From Figure 1, though, it is clear what should happen: the butterfly wing should close to a tip. To get this correct, we must include the endpoints of the interval [−4, 4] as the closing point for the wing.
We will see in the next sections that we need additional closures to complete the smaller butterfly wingtips.

Gap labelling: inverse slope 2
We continue with the gap labelling, looking at gaps with label r = 2 * p − s * q; that is, wings with inverse slope 2. For s = 0, 1, we get the wings shown in Figure 4, the first diagram covering a θ range of [0, 1/2] and the second covering range [1/2, 1]. Note that we must close the wingtips at θ = 0, 1/2, 1, just as we did in the last section, selecting the min/max spectral endpoints, rather than a gap.
However, we also see a new phenomena. Again in Figure 4, on the left diagram, there is an extraneous segment connecting two distinct wings, at the vertical value θ = 1/3. Similarly, in the the right diagram, there is a segment at θ = 2/3. This is in fact a discontinuity in the gap labelling. At θ = 1/3, there is a jump in the gap. If we try to draw that jump line, we would get a line cutting across the larger butterfly wing drawn in the last section. (The wing with inverse slope t = −1.) So, we should remove these discontinuities. Again, we want to close the wingtips, so at θ = 1/3 we choose the same spectral endpoint to close the wingtip. Specifically, when coming up from below, we pick a right endpoint of a spectral interval. When coming down from above, we pick a left spectral endpoint. This is exactly as we did with the endpoints θ = 0, 1.

Gap labelling: inverse slope 3
We continue the construction of butterfly wings, by labelling gaps with inverse slope t = 3. In this case we have three choices for s, as s = 0, 1, 2, giving the diagrams in Figures 6, 7  . We must close wingtips at the endpoints of these ranges (i.e. at 0, 1/3, 2/3, 1), but we also notice cutting segments again.  Figure 6. Butterfly wings at inverse slope 3, s = 0. Cutting segments on the left, at θ = 1/5, 1/4, and removed on the right.
In Figure 6, on the left, the cutting segments are clearly at θ = 1/5 and θ = 1/4. Removing the cutting segments and closing the wingtips gives the right diagram in Figure 6.
In Figure 7, on the left, the cutting segments are not quite so clear, but a close examination shows there are segments at θ = 2/5 and θ = 3/5. Removing the cutting segments and closing the wingtips gives the right diagram in Figure 7.  In Figure 8, on the left, the cutting segments are at θ = 3/4 and θ = 4/5. Removing the cutting segments and closing the wingtips gives the right diagram in Figure 8.
6. Gap labelling: inverse slope 4 As we go to higher inverse slope t, it is harder to eyeball where the discontinuities should be.
In the last interval, we expect wingtips (discontinuities) at θ = 3/4, 4/5, 5/6, 6/7, 1, which we can guess just from the patterns that occurred at slopes t = 2, 3.  However, on the interval [1/4, 1/2], it is not so clear, so it helps to do some numerical experimentation. In Figure 9, we plot the jumps in the gap as θ increases. At the labelled points, we note significant jumps at the vertical values θ = 0.2861, 0.3341, 0.4005, 0.4289.
Estimating in terms of fractional values, these jumps are at θ values 2/7, 1/3, 2/5, 3/7. Significantly, there are four jump values -whereas from the other examples, we might have only expected 3 = t − 1 values. In Section 8, on the gap labelling conjecture, we show why there are four jump points.
Using this jump data, we remove cutting lines and obtain the inverse slope 4 wings shown in Figure 10.

Sanity check: another jump at inverse slope 4?
Looking carefully at Figure 9, it appears there is another significant gap jump at a θ value of about .38. Examining our numbers carefully in MATLAB, we find a value of θ = 0.3747, which is about θ = 3/8.
Is there a jump here? No. This value corresponds to the spectral point zero, the centre of the butterfly pattern, where the inverse of the butterfly curves flattens out -so we have large movement, even though there is no jump.
We note that t * θ −s, at θ = 3/8, gives the value 1/2, the midpoint of the butterfly, or spectral value of zero.

Gap labelling: inverse slope 5
At inverse slope 5, it is very difficult to guestimate where the discontinuities should be. However, in the next section of this paper, we have a conjecture predicting the gap jumps for θ values of the form where we are following the gap curve r = t o * p − s o * q, with t o > s o ≥ 0. For inverse slope 5, we set t o = 5 and s o = 0, 1, 2, 3, 4. We use these fixed values, and the range of t, s allowed above to pick out discontinuities, and then plot. Again, we must close the wingtips following the usual algorithm of matching endpoints of the appropriate spectral intervals. Figure 12 shows the collection of all the butterfly wings with inverse slope 5, all cutting lines removed, and wingtips closed, using the conjectured gap discontinuities. The image looks correct, suggesting that the conjecture works for inverse slope 5. For r = t*p + s*q, 5<= t <= 5 Figure 11. Butterfly wings at inverse slope 5, s = 0, 1, 2, 3, 4.

Gap labelling: discontinuity conjecture
We observe the apparent discontinuities in the gap labelling can be determined by the following algorithm.
Algorithm: For a given labelling r = t o * p − s o q, say with t o > 0, we plot the positive sloping line in (x, θ) given by the equation and all the negative sloped lines in (x, θ) given by where (t, s) are integers satisfying 0 < s ≤ t < t o . Note that (−t, −s) is a valid index for a negative slope gap labelling.
Conjecture: The intersection of all these lines, in the region 0 < x < 1 give the gap discontinuities.
Visually, we can see the intersections. For instance, in the case of a line slope t o = 2, we see in Figure 12 the relevant lines for s 0 = 0 (on the left) and s o = 1 on the right, giving the intersections at θ = 1/3 and θ = 2/3 respectively.  Figure 12. Line intersections specify the discontinuity points for slope 2, s = 0, 1. On left, red line indexed as (2,0) has intersection at θ = 1/3. On right, red line indexed as (2,1) has intersection at θ = 2/3.
The case of slope t o = 4 is particularly interesting, as this is the first level where the "pattern" of jump discontinuities is not immediately clear. Looking at Figure 14, for the line of index (4, 1), we see gap discontinuities predicted at values θ = 2/7, 1/3, 2/5, 3/7, just as we determined numerically in Section 6. This seems to confirm that the algorithm is promising (and perhaps correct).
It is useful to state specifically the conjecture about the gap discontinuities: Theorem 1 (Conjecture). For gaps labelled by the Diophantine equation there are discontinuities in the gap labelling at values θ of the form for all integers t, s satisfying 0 < s ≤ t < t o , and restricted to the open interval Closing the gaps at the discontinuities gives the butterfly wingtips.
We do not have a proof of this result, only numerical evidence to confirm it. The predicted discontinuities also include the zero-length gaps in the spectral intervals, where two intervls touch at spectral value zero. Including these points in the plotting algorithm does not disturb our images.
As the final numerical test of the conjecture, we note that the butterfly image in Figure 2 was computed using this algorithm for detecting discontinuities in the gap labelling, and we observe that Figure 2 is an excellent rendering of the butterflies apparent in the original spectral map in Figure 1. Figure 2 includes all gap labelling with all non-zero inverse slopes in the range −10 ≤ t ≤ 10. It looks correct, suggesting the algorithm to remove gap discontinuities is working correctly.
In the appendix we include a figure with gap labelling for all non-zero inverse slopes in the range −20 ≤ t ≤ 20. Again, we see no obvious breakdown in the algorithm used to remove the gap discontinuities.

Sanity check: zooming in on discontinuities
As a check that our algorithm for predicting the discontinuities in the gap labelling is correct, we will examine closely the image at an unexpected discontinuity.
As mentioned in Section 6, the discontinuity on line (t o , s o ) = (4, 1) at θ = 2/7 was unexpected. For this line, we were expecting only three discontinuities, as there are big jumps at the three values θ = 1/3, 2/5, 3/7. The value 2/7 doesn't quite fit the apparent pattern, and yet the conjecture says there should be a discontinuity there.
To test this, we plot side-by-side the butterfly image using spectral lines, and using the new algorithm for the drawing the labelled gaps, zoomed in at the possible discontinuity point θ = 2/7. The two images are shown in Figure 15. Notice how the horizontal line exactly at the center (left image) has a gap -so there really is a spectral gap at θ = 2/7. The image on the right, showing the butterfly, accurately captures this gap -that is, we see the main butterfly image here has a gap at the centre. So the algorithm successfully identified the gap discontinuity in this case.
It is significant, and worth noting, that the two wingtips at the centre of the diagram do not meet, and are slightly offset. It is an interesting phenomenon, accurately rendered both with spectral lines (left image in Figure 15) and with the butterflies (right image in Figure 15).

Sanity check: other coupling constants
It is a useful check on the algorithm to verify that the butterfly structures maintain the same basic form under small modifications of the setup of the problem. The Bloch Figure 15. Comparing the discontinuity at θ = 2/7, zoomed in. electron model includes a physical parameter called the coupling constant λ which is generically set equal to 2. For the general problem, one can consider self-adjoint operators of the form where λ is a positive real parameter. It is known that the gap structure for the corresponding spectra remains the same (Bellissard and Simon, 1982). We run our code as before, only changing the coupling parameter λ and see that the basic form of the result looks the same. FIgure 7 shows three results, for three different values of the coupling parameter. Note the width of the result varies with λ, and in fact the width is proportional to 2 + λ. Other than the width differences, the butterfly structures look very similar, and we do not observe any breakdown in the algorithm that predicts the gap discontinuities. Again this is evidence of a good conjecture.

Future work
It would be useful to have a function that can select, then draw, individual pairs of butterfly wings. As things stand now, we only get half-wings of certain slopes, and it is not clear how to label them and put them all together.
This may be related to the fractal structure of the Hofstadter butterfly, which we supsect is somehow indexed by SL 2 (Z).

Summary
We have presented a new rendering of the Hofstadter butterfly based on explicit drawings of the spectral gaps using the gap labelling method of K-theory. Discontinuities in the gap positions are revealed by this method, and we present a conjecture for identifying where the discontinuities occur, and how to "close" the the wing tips at the discontinuities. We have presented numerical evidence to suggest the conjecture is correct, and results in an accurate rendering of the fract-like structure for the Hofstadter butterfly.
As a side note, we observe the utility of programming our mathematical illustrations directly in the PostScript language, for optimum resolution.
In all cases, the algorithm for predicting the gap discontinuities successfully removes any extraneous lines.