COUNTING MONOCHROMATIC REGIONS

BY JACOB RICHEY

Abstract
Given a chessboard of dimensions m by n whose squares we color either black or white (with equal probability), what is the expected number of connected monochromatic regions? While there is likely no explicit form for the number, we explore various ways to estimate the expected value, and simulate in MATLAB the coloring to determine numerical values for the expectation. We explore generalizations of this question as well as variants on the problem: what if we connect the ends of the chessboard to form a doughnut? What if there are more than two colors? What about a hexagonally-tiled chessboard, or a three dimensional box (where we color the lattice cubes)? More generally, what is the expected number of connected monochromatic subgraphs of a finite graph whose vertices are two-colored? There are some pieces of these problems we can solve completely, but we will see that in general counting monochromatic regions is a difficult task. We also investigate a related question: what is the expected size of such a region? One might expect that we could calculate the expected number from the expected size (since, for any given colored chessboard, the average size of a region is exactly the area of the board divided by the number of regions), but unfortunately this is not the case. The question is still an interesting one, and we will see that it can at least give us a bound for the expected number of monochromatic regions, as well as an equivalent way of investigating the same problem.

1 Bounds for E (m, n)
The inspiration for this problem came from a question on the William Lowell Putnam Mathematics Competition in 2005, which asked for proof that the expected number of regions E (m, n) is bounded from below by mn . As it turns out, this is a reasonably good bound: we’ll 8 use this to discuss how we might begin estimating E . One idea is the following: we can write
1

2

BY JACOB RICHEY

Figure 1 E (m, n) =
mn i=1

Ei (m, n),

where Ei is the expected number of regions of size i. We can use this to get a lower bound for E , since each Ei ≥ 0 and, at least for small i, we can calculate Ei explicitly. For example, E1 is the expected number of regions of size 1, which is the sum of the expected number of size 1 monochromatic regions in each square: that is, the sum of the probabilities that each square is, by itself, a monochromatic region. To make the calculation simpler, we can neglect the edges (where the probability of a square being a monochromatic regions is higher, since fewer of its neighbors have to be different colors), so that E1 ≥ mn , since 24 the square would have to be the opposite color of its four neighbors. To obtain the actual value, we can sum over the three different cases: where the square has four neighbors (in the “interior” of the chessboard), where it has three neighbors (on one of the four edges), or where it has two neighbors (one of the corners). (See figure 1.) Explicitly,

COUNTING MONOCHROMATIC REGIONS
E1 = E1 =
(m−2)(n−2) 16 (m+2)(n+2) 16

3

+

2(m−2+n−2) 8

+

4 4

This is a little better than half of what we wanted: not bad for a first try. It is interesting to note that the answer itself is the expected number of monochromatic regions of size one on a m + 2 by n + 2 chessboard that wraps around on itself, where every square is adjacent to exactly four other squares (this is the problem our lazy estimate was thinking of). This coincidence is the result of a geometric artifact: consider both figures, a regular m by n chessboard with no wrapping, and an m + 2 by n + 2 chessboard with wrapping. The interior (m − 2)(n − 2) squares of both have the same probability of being size 1 monochromatic regions, since in that area in either figure all the squares have exactly four neighbors. On the border of the m by n chessboard, n−2) n we calculated that there were 2(m−2+ +4 = m+ expected size one 8 4 4 regions (the last two terms in our sum for E1 ): the result is exactly the same for the remaining part of the m + 2 by n + 2 chessboard, since there are exactly 4(m − 2)+ 4(n − 2) +16 = 4m +4n remaining squares, each of which has 1/16 chance of being a size 1 monochromatic region, +4n n so the expected number of such regions is 4m16 = m+ . 4 If we add on E2 , the estimate gets a little better, but not by much: E2 = E2 =
4(m−4)(n−4) 27

+ 2(m − 4 + n − 4)[ 237 + 216 ] + 4[ 227 + 2(m − 2 + n − 2)[ 216 + 225 ] + 8[ 216 + 215 + 214 ] + 284

2 ]+ 26

2mn+7m+7n+52 64

(We are counting the expected number of monochromatic 2 by 1 rectangles, splitting into six different cases that the square could be in: see figure 2.) Then the new estimate is E1 + E2 =
1 (6mn 64

+ 15n + 15m + 68) ≈

mn 11

This method would give us an exact value if we had some way of explicitly calculating the Ei ’s, but unfortunately past i = 2 they get significantly more complicated, since the possible size-i regions come in more than just one flavor: with i = 1 all we had was a square, and with i = 2 we only had the 2 x 1 rectangle, but for i = 3, for

4

BY JACOB RICHEY

Figure 2 example, we have both the 1 x 3 rectangle and the corner piece (a 2 x 2 with one block missing). In general we would have to consider planar polyominoes, and since the polyominoes don’t all have the same number of neighboring squares, we would have to work out the expected number of each kind of polyomino. In other words, this method is only going to get us lower bounds, never an explicit formula. We were able to work out a lower bound for E3 , E4 and E5 by calculating their values for the wraparound scenario: with those values, we obtain a lower bound of E (m, n) ≥ mn , which is the best lower bound we have to date. 7 directly, We now show a way to prove the lower bound E (m, n) ≥ mn 8 1 using a very different approach (due to Noam Elkies) : we will build the m by n rectangle by recursion on the number of squares, showing that each square we add increases the expected number of monochromatic regions by at least 1 . We build one row at a time, starting from the left 8 and adding squares on the right until the row is complete, then begin
1http://amc.maa.org/a-activities/a7-problems/putnam/-pdf/2004s.pdf

COUNTING MONOCHROMATIC REGIONS

5

Figure 3. A plot of E (i, i) for 1 ≤ i ≤ 20, computed in MATLAB

at the left of the next row. The first square adds 1 to the expected number, so the base case is satisfied. In fact, the entire first row is a special case; if we are adding to the first row, there are two possibilites: it matches or doesn’t match the square to its left. In the first case it adds 0 to the expected number, and in the second it adds 1 (with equal probability of both), so that the expected number of new regions is 1 > 1 . This also covers the case where we are adding the first square 2 8 of a new row. Now there is only one remaining case: when the new square has as neighbors the square above it and the square to its left. Then there is a1 chance that we get an additional region, if the new square matches 4 neither of its neighbors, and 1 chance that the new square matches 8 its neighbors and is opposite in color from the square above its left neighbor (or to the left of its above neighbor), in which case the expected number decreases by 1 or stays the same. In any other case, the expected number of new regions is 0. Therefore, the total expected −1∗ 1 +0 = 1 , the desired number of new regions is at least 1 ∗ 1 4 8 8 result. There may be a way to extend this recursive approach to get

6

BY JACOB RICHEY

Figure 4. A plot of E ∗ (i, i) for 1 ≤ i ≤ 20. an even better bound, but it would be quite laborious: we should be bound we have. satisfied with the mn 7

2 Computing E (m, n)
Finding an efficient way to compute the number of monochromatic regions in a square is difficult: our method uses the strengths of MATLAB’s random numbers to perform the task. (We also calculate E ∗ (m, n) - the expected number of monochromatic regions on chessboard with wraparound - using the same method.) In particular, the method first generates a coloring of the chessboard, then generates an m by n array of the numbers 1 through the total number of monochromatic regions in the following manner: beginning with square (1,1) and moving row by row as in our theoretical method, it assigns the square a number, then randomly jumps to any square it neighbors with the same color and assigns that square the same number, repeating this process some (large) fixed number of times. In this way, we obtain an array with the following property: two squares (x, y ) and (u, v ) are in the same

COUNTING MONOCHROMATIC REGIONS

7

monochromatic region if and only if the value of the array at (x, y ) equals that at (u, v ). We need only know how many different numbers there are in this array: this is exactly the number of monochromatic regions. We also analyze the doughnut case (the chessboard with wraparound) using the same method. For either program, the computation becomes hefty for n, m ≈ 25, since our program increases the number of jumps it does per region with the area (it has to, else we might not properly label some of the regions, since the regions can be as large as the area of the board). Figures 3 - 5 represent computed values for E (m, n) for m, n ∈ [1, 20]. (E (m, n) = E (n, m) by symmetry, so we consider only m ∈ [1, 20], n ∈ [m, 20]). Our first attempt at computing E (m, n) was this: to assign to each square on the chessboard a number, either 0, 1 or -1, depending on the colors of two of its neighbors, in particular its upper and left neighbors. The idea is to count the number of regions by counting each square’s contribution to that total. If a square only has a left or upper neighbor, we assign a 0 if it is the same color as that neighbor and a 1 if it is the opposite color. In the case that it has neither of these (as in the top-left most square), we assign a 1. If both neighbors exist, then we assign a 1 if it differs in color from both its neighbors, a 0 if it matches one but not the other, and a -1 if it matches both. This seems like it should work: a 1 represents a new region being formed, a 0 represents a square belonging to some already present region, and a -1 takes away what we’ve overcounted (the idea being that it is “connecting” two regions that were previously thought be be disconnected, but in reality are part of the same region). While it works in a few cases, in general it gives a lower bound for the expected number of regions. What happens is, we get some extra -1’s popping up where they shouldn’t: in particular, whenever there is a cycle (a closed monochromatic loop through some squares on the chessboard), we get an extra -1 where there shouldn’t be one; this happens because the method “thought” the two neighbors of a square were previously unconnected and subtracted 1 in connecting them. In reality, they were already connected somewhere else on the chessboard. What the method actually counts is the number of monochromatic regions minus the Euler characteristic χ of the board (where regions are defined by colors): the cycles correspond to “holes” in the figure, (the squares that they surround), and topologically “holes” decrease the Euler characteristic by 1. In particular, the value we get for E (m, n) − χ

8

BY JACOB RICHEY

Figure 5

is the sum of the expected values over all the squares: for any square 1 with both an upper and left neighbor, the contribution is 4 ∗1+ 1 ∗ 2 1 0 + 4 ∗ 1 = 0, and that for squares with only left or upper neighbors is 1 ∗1+ 1 ∗0= 1 , so that 2 2 2
1 E (m, n) − χ(m, n) = 2 (m + n − 2) + 1 = m+n . 2

This is quite far from the expected number of regions, which (as we saw) grows at least with a constant factor of the area of the chessboard, while this is only growing with the lengths of the chessboard. Note that for a chessboard with wraparound (i.e. a doughnut), we obtain E (m, n) − χ∗ (m, n) = mn ∗ 0 = 0,

COUNTING MONOCHROMATIC REGIONS

9

so that the expected Euler characteristic of a 2-colored lattice on a doughnut is zero. That is, the expected number of monochromatic regions is the same as the expected number of cycles, a seemingly strange coincidence. It may be worthwhile to try and estimate how often cycles occur: if we can somehow get a hold of bounds for cycles, or characterize the most common cycles, we may be able to correct this estimate and get an estimate for E (m, n) out of this. Another seemingly better method for computing the expected number of regions E (m, n) was proposed: we consider the adjacency matrix associated with each random chessboard - that is, an mn by mn square matrix whose (i, j )th entry is a 1 if a square i and square j on the chessboard neighbor eachother and have the same color, and a 0 otherwise. Call this matrix A. If we add the mn idendity matrix to A, we get a transition matrix for the chessboard: that is, (A + I )p represents the p-step (monochromatic) transition matrix. If we take p = mn − 1, (a very safe upper bound for the number of steps we ever need to get from one square to another), we have a transition matrix that identifies exactly what the connected monochromatic regions are: any two squares in the same region will share the same entries in this matrix. That is, the number of distinct rows in the matrix is exactly the number of monochromatic regions. We can count this by taking the rank of this matrix: therefore, the number of monochromatic regions is just the rank of the matrix (A + I )mn−1 . There are two problems that arise with this method. The first is minor but annoying: MATLAB’s tolerance for small numbers being equal to zero is too large in some cases, so in taking powers of this matrix, there is a little error. It translates to the computed number of regions being off by one (sometimes). The bigger problem is that this program runs even slower than our first algorithm, even for more carefully chosen powers p, rendering it relatively useless.

3 Estimating S (m, n)
Another related quantity we can try and estimate is S (m, n), the expected size of a monochromatic region in an m by n chessboard. For small m and n this number gets distorted by edge effects, so we’ll just try and calculate the expected size for sufficiently large m and

10

BY JACOB RICHEY

n, i.e. supposing that every square has exactly four neighbors. The objects we consider to calculate this value aren’t monochromatic regions, but rather monochromaticpaths in Euclidean 2-space. That is, we randomly color every point in the Euclidean plane either black or white, and ask: what is the expected length of a monochromatic path, starting from the origin (and stepping one unit at a time)? This should give us a lower bound for S , since we are only “counting” the lattice points we step on as part of our path length, while there is some positive probability that there may be multiple lattice points connected to our monochromatic path (and so the associated monochromatic region would have area larger than the length of our path). How will we estimate S ? We can’t characterize all the (infinite) paths and their respective probabilities: the biggest obstacle with a completely general approach is the problem of self-intersection, which we can’t regularly model. But we can take one the most common path (or a somewhat general path) that we know doesn’t self-intersect and find its expected length: then S will be at least this much. As a simple example, we could calculate the expected length of a straight line path, one where we keep going in the same direction, so long as the next square is the same color. This path has expected length s1 = 1 + 15 (1 + 1 + 1 + . . .), since we have a 15 chance of being 16 2 4 16 able to take our first step away from the origin (since there is a 1/16 chance that none of those four squares are the same color as the origin), and then each successive step has a 1/2 chance of being legal. Then 30 46 s1 = 1 + 16 = 16 ≈ 2.8 units. This isn’t a very good approximation: we can get much better ones by considering cooler/more general paths. Consider, for example, the set of paths where we only move in one of two directions (e.g. only North and East). That is, after our first step from the origin, (WLOG to the North), we’ll only take steps North and East. This kind of path is guaranteed not to intersect itself, since we never decrease the absolute value of the sum of the coordinates of our position. This kind of path has expected length equal to (by similar reasoning) s2 = 15 9 1 + 16 (1 + 3 + 16 + . . .) = 1 + 60 = 19 = 4.75. This is about as good as it 4 16 4 gets without getting too messy. We did try one other relativley simple general path, where we (WLOG) alternate taking up steps, and left, up or right steps. That is, first we take a step in some direction of the four possibilities (WLOG up), then either go left, up or right, then go up, and so on. It is easy to see that this avoids self-intersection: it has 7 1 49 1 (1 + 7 +8 ∗ 2 + 64 ∗ 2 + . . .). To calculate the expected length s3 = 1 + 15 16 8

COUNTING MONOCHROMATIC REGIONS

11

value of this, we have to find the value of the “alternating geometric series” 1 + p + pq + p2 q + p2 q 2 + . . .. The series converges for p, q < 1 since the regular geometric series in both p and q do, and we have 1 + p + pq + p2 q + . . . < 1 + p + p + p2 + p2 + . . . = 1 + 2 p + 2 p2 + 2 p3 + . . . < 2 + 2 p + 2 p2 . . . =
2 1−p

<∞

Therefore, we can assume that the series converges to some limit: call it L. Then we have L = 1 + p + pq + p2 q + . . . L = 1 + p + pq (1 + p + pq + . . .) L = 1 + p + pqL L=
1+p 1−pq

Therefore, we have s3 = 1+ 15 ∗ 15/8 = 33 , which is less than what we 16 9/16 8 got for s2 . (This surprised me a little, since it feels like this is covering more area than the other method.) Already, we can see that for large enough m and n, we won’t have E (m, n) ∗ S = mn (as one might naively expect), since that would say mn that a lower bound for E is 1928 ≈ mn , which is much larger than our 1.5 computations expect. The reason this isn’t working is that the number of regions and average size of the regions for a given chessboard aren’t independent random variables. It isn’t hard to check that in general, the expected value of a product isn’t the same as the product of the values. If we have two N element sets of (positive) real numbers, A and B with the property that ai bi = C for some constant C ∈ R, it is not necessarily true that the mean of the ai ’s a and the mean of the bi ’s b have ab = C , since ab = = =
1 (a1 N2

+ . . . + aN )(a1 + . . . + bN )

1 ((a1 b1 +. . .+aN bN )+(a1 b2 +. . .+a1 bN )+. . .+(aN b1 +. . .+aN bN −1 )) N2 1 ( a1 b 1 N

+ . . . + aN b N )

12

BY JACOB RICHEY

Figure 6. A histogram of the computed values of S with 105 trials. For example, take A = (1, 2), B = (4, 2) =⇒ a1 b1 = a2 b2 = 4, but 3 ∗3= 9 = 4. ab = 2 2 Here A represents the set of measurements for the number of monochromatic regions in an n by m chessboard, and B represents the set of measurements for the average size of those regions. Then in each case we have that the product of the number of regions and the average size of the regions equals exactly the area (the constant C ), but (as this shows) the average measurements don’t necessarily satisfy the same property.

4 Computing S
Computing the expected length of a monochromatic walk in the plane is an easier task than computing E (m, n), and we do so by simulating it directly. That is, we have a random walker start at the origin, then walk to a random neighboring square if it has the same color and he hasn’t been there before. When he can’t walk anywhere, the path is done. The computation gives the value S = 7.20, which is significantly longer than our estimates predicted (but not all that long). The values of S appear to be Chi-squared distributed, which could give us a way to calculate how refined our estimates for E (m, n) were: recall that we were using higher and higher degree polyominoes to get lower bounds

COUNTING MONOCHROMATIC REGIONS

13

Figure 7. A plot of E (25, 25, p), p ∈ (0, 1) on E . This analysis of S shows that we really need to go out to the 7-degree polyominoes, and maybe a little on either side.

5 Other Questions
Most of the questions we posed remain unsolved for now: it remains to be seen what allowing more colors, changing the lattice, allowing more dimensions, or considering stranger objects (e.g. a map of the United States or complete graphs Kn ) would look like. We were able to answer the question: what happens if we change the probability of getting a particular color in randomly generating the chessboard? If we have probability p of getting white (and 1 − p of black), then as p → 1, we should have E (m, n, p) = 1, since then almost all the squares will be the same color. Figure 9 is a plot of E (25, 25, p) for p ∈ (0, 1) with 1 steps of 50 . The plot appears to be parabolic, with maximum value at 1 p = 2 as we might have expected. In conclusion, we note that it isn’t completely impossible to calculate the expected number of regions: we can calculate it explicitly for a 1 by n rectangle, using the method we have for calculating χ. In fact, the expected Euler number of a 1 by n rectangle is exactly its Euler

14

BY JACOB RICHEY

characteristic χ, since no cycles can exist in a 1 by n rectangle. Thus, the expected number of monochromatic regions is E (1, n) = n+1 . 2

Sign up to vote on this title
UsefulNot useful