Surprising Sequences This session will explore the Mathematics involved in four problems, which lead to (relatively!) surprising sequences. Each of these problems could be introduced as enrichment material in the classroom for students of a variety of ages without any prior knowledge. These tasks could be used as investigations in which students could be given a ‘flexible’ amount of time to establish the sequence and in which there is little danger of someone establishing ‘the correct pattern’ immediately. The Mathematics can then be discussed with them, in all cases using arithmetic examples and minimal algebra. However, a facility with algebra is always beneficial and, as a word of caution, some of the Mathematics involved in understanding the Reve puzzle, in particular, demands a level of mathematical abstraction not normally found in younger students. The problems are: (1) The maximum number of regions in a circle for a given number of points on the circumference all connected with chords, leading to the sequence starting: 1, 2, 4..….. (2) The positive integers that can be written as the sum of distinct triangular numbers, leading to the sequence starting: 1, 3, 4.…… (3) The probability of 2n prisoners all finding the key to their own cell when these (identically looking!) keys are rearranged ‘randomly’ in the 2n cells and each prisoner is allowed to look in a maximum of n cells without discussing their findings with any other 23 ........ prisoner, leading to the sequence starting: 12 , 125 , 60 (4) The number of moves required to transfer n discs of different size from one peg to another without placing any disc on top of a larger one in the Tower of Hanoi problem for four pegs, known as the Reve puzzle, leading to the sequence starting: 1, 3, 5…….. Notes for MEI session at 10.30 on Friday 27th June: John Cooper Surprising sequences: points and regions in a circle When a number of points (n) are marked on the circumference of a circle and connected with straight lines (chords), the maximum number of regions created (r) is given by: r 1 12 n(n 1) 241 n(n 1)(n 2)(n 3) For n ≥ 4, this formula can be written: r 1 C2n C4n The reason why we need to stipulate the maximum number of regions is that, if three lines meet at the same interior point, a region is effectively ‘lost’. When demonstrating this result by drawing chords of a circle and counting regions, care should be taken to ensure that no three lines meet at a single interior point. Firstly, the formula is correct for n = 1. With one point only on the circumference there are no lines drawn and there is exactly one region (the whole circle). Next, every additional line that does not cross any other line splits a region in two and creates an extra region. When a line crosses k other lines (i.e. it intersects other lines at k interior points or ‘crossing’ points) it splits k + 1 regions into a total of 2(k + 1) regions so has the effect of creating k + 1 additional regions (provided that a new line does not cross two lines at the same interior point). Hence the total (maximum) number of regions is 1 + the number of lines + the number of interior points. But each line (chord) is uniquely determined by a pair of points on the circumference. So, for n ≥ 2, the number of lines (l) is given by: l C2n Also, each interior point (crossing point) is uniquely determined by every selection of four points on the circumference. So, for n ≥ 4, the number of crossing points is given by: c C4n Putting all this together, the maximum number of regions created is given by: r = 1 + the number of lines + the number of crossing points r 1 C2n C4n What is striking about this result is that the first few terms are: 1, 2, 4, 8 and 16 A cursory glance might suggest that the pattern is ‘doubling’. This is not the case. The next few terms are: 31, 57, 99 and 163. This serves as an excellent example with which to stress the inadequacy of trying to extend a sequence by ‘continuing the pattern’ of the first few terms! Surprising sequences: sum of distinct triangular numbers Every integer > 33 may be expressed as the sum of distinct triangular numbers Firstly, by inspection, the only positive integers < 36 that are not so expressible are: 2, 5, 8, 12, 23 and 33………………………………………………………..(1) Next, all square numbers may be written as the sum of two (consecutive and therefore distinct) triangular numbers since, if tn 12 n(n 1) is the nth triangular number, n2 tn tn1 We aim to prove the result by induction on n. Suppose that all integers ≤ n2 may be expressed as the sum of distinct triangular numbers. Now every integer m: n2 < m < (n+1)2 may be written as m = n2 + k where 1 ≤ k ≤ 2n and, since 2n < n2 for n > 2, by the induction hypothesis k may be expressible as the sum of distinct triangular numbers unless k is a member of list 1 above. If k is not from list 1, m tn tn1 the sum of distinct triangular numbers. Fortunately, if k is from list 1, k = 2 + tp In such cases m may be written: But (or, in the case of 33, 33 2 t2 t7 ) m = n2 + 2 + no more than two (distinct) triangular numbers n2 2 tn1 tn2 So, in these cases, m tn1 tn2 no more than two (distinct) triangular numbers. Hence, whether or not k is from list 1, m can be expressed as the sum of triangular numbers. We now just need to check that there is no overlap between the numbers that make up k (or k – 2) and those that make up n2 (or n2 + 2). For this, we require: 1 2 n(n 1) 2n and 12 (n 1)(n 2) 2(n 1) The latter condition is stronger and leads to: (n 1)(n 6) 0 So, n > 6 (since n is positive). Hence we should either check all cases up to n2 = 49 and start the induction at n = 7 or start the induction at n = 6 and be aware that there is a potential clash when k = 12 (48 = 36 +12 = 38 +10 = 28 + 10 + 10) but that this can be written: 48 = 28 + 10 + 6 + 3 + 1. If we start at n = 7 then it follows from the above argument that the result holds for all integers n2 ≤ 64 and so, by induction, the result holds for all integers > 33. Surprising sequences: (2n) prisoners The initial problem features 100 prisoners who have been told that the keys to their 100 individual cells (numbered from 1 to 100) have all been swapped around and placed in the lock of a ‘random’ cell (one to a cell). Each prisoner is allowed to visit at most 50 cells in an attempt to find the key to their cell (each key is clearly labelled with the number of the cell that it opens). The governor has agreed to release all prisoners if they can each find the key to their cell. The prisoners are allowed to discuss a strategy beforehand but are not allowed to communicate once the search (which takes place ‘one at a time’) has started. Each prisoner must leave all keys where they are found so that the next prisoner is faced with exactly the same ‘permutation’ of keys. If the prisoners do not decide a strategy and behave ‘independently’ their chances of escape 1 are slim! P(all prisoners find the correct keys 2100 ). However, their prospects can be improved considerably (but not guaranteed!) by adopting a particular strategy. All prisoners agree to look for their key firstly in their own cell and then in the cell with the same number as the key found. They continue this process until they find their own key (or not!). So, in a simpler example of four cells and keys, in which each prisoner has two chances to find the correct key, suppose cells 1, 2, 3 and 4 contain the keys 2, 1, 4, 3 respectively. This permutation could be written more efficiently in cycle notation as: (1 2) (3 4). In this case, two attempts would be enough for all prisoners to find the correct key and be released. However, this only happens because the maximum length of a cycle in this permutation is two. The permutation (123)(4) in which key 2 is in cell 1, key 3 is in cell 2, key 1 is in cell 3 and key 4 is in cell 4 would mean that, adopting the above strategy, three of the prisoners (1, 2 and 3) would each fail to find the correct key. Suppose, in general, that there are 2n prisoners who adopt the agreed strategy. Then they will each find their own key in at most n visits unless the permutation of the first 2n integers produced by the numbers of keys in cells 1,2,3 ……..2n contains a cycle of period > n. Suppose that the permutation contains an m-cycle (necessarily unique) with m > n. Then there are: Cm2n ways of selecting the numbers involved in the m-cycle, (m - 1)! possible cycles with these numbers and (2n - m)! ways of arranging the other numbers. Cm2 n (m 1)!(2n m)! = (2n)! 1 = m P(permutation contains such a cycle of m) 2n So, P(permutation contains a cycle of period > n) = 1 (since such ‘long’ cycles are m n 1 m mutually exclusive). Hence the probability of 2n prisoners all surviving if they adopt this strategy is given by: P(2n survive) = 1 This leads to the ‘surprising’ sequence: 12 , 5 12 , 23 60 2n 1 m n 1 m , 307 840 …………for 2, 4, 6, 8…. prisoners. This is particularly surprising as no member of the sequence < 0.3. By considering the area under the graph of y 2n we obtain: So, 1 m n 1 m 2n n 1 between x n and x 2n x 2 n 1 1 1 dx x mn m P(prisoners do not survive) < ln2 < P(prisoners do not survive) + 1 2n Hence, even though the harmonic series is divergent, its ‘smaller half’ is not! Surprising sequences: the Reve puzzle The Tower of Hanoi problem with three pegs is well known. Less well known is the version with four pegs, known as the Reve puzzle. Firstly, we consider the problem with three pegs. Let g(n) be the minimum number of moves to transfer n discs of differing radii from one peg to one of the other two without placing any disc on top of a smaller one. Then g(n) is given by: g(n) = 2n – 1 With n discs, the top n -1 discs have to be moved and completely reassembled before the last (nth) disc can move, after which the top n -1 discs again all have to be moved and reassembled. Since this operation is also possible, the process can be summarized by an inductive definition: g(1) = 1 and g(n+1) = 2g(n) + 1 leading, via induction, to the formula: g(n) = 2n – 1 It is also worth noting that, if the discs are numbered from 1 to n with disc 1 being the smallest, then, to ensure a legal move, disc 1 moves first, last and on every other move. Hence the total number of moves of disc 1 is 2n-1. Ignoring all the moves of disc 1 and considering all the other moves, it is also clear that disc 2 moves first, last and on every other move. Hence the total number of moves of disc 2 is 2n-2 and the last disc moves only once. So the total number of moves of all the discs is: g(n) = 1 + 2 + 22 + ……… + 2n-2 + 2n-1 i.e a geometric series with sum 2n – 1 as above. This gives an alternative proof without using induction. It also leads to an algorithm (one of many!) for moving the discs. For example, with 4 discs, the process can be completed via the following sequence: 121312141213121, where the numbers refer to the disc being moved. Unfortunately, the corresponding result for four pegs (the Reve puzzle) is much harder. Indeed as far as I know it has not yet been proved, although a ‘probable’ formula has been established! Let f(n) be the minimum number of moves to transfer n discs from one peg to one of the other three. Then the first few results are given in the following table. For comparison, the corresponding results (g(n)) for three pegs are also given. n f(n) g(n) 1 1 1 2 3 3 3 5 7 4 9 15 5 13 31 6 17 63 7 25 127 8 33 255 9 41 511 10 49 1023 11 65 2047 12 81 4095 13 99 8191 14 113 16383 15 129 32767 Note that the number of moves required for, say, fifteen discs is far fewer with four pegs than with three! The strategy for transferring n discs using four pegs that is believed to be optimal is to transfer m discs (m < n) (if m = n we have made no progress!) using all four pegs, then to transfer the remaining n – m discs using only the three ‘legal’ pegs and finally to ‘retransfer’ the first m discs, again using all four pegs. So, f(1) = 1 and f(n) = 2f(m) + g(n-m)…………………………………………(1) where m is chosen to minimize the total number of moves. The problem is that it has never been proved that it is always better to transfer whole ‘subtowers’ of discs so that, just before the last peg moves, there are two subtowers of discs each containing ‘consecutive’ discs on two pegs, in addition to the last disc on the first peg. It is theoretically possible that there is a better solution that does not split naturally into subtowers. For example, there is a solution for four discs, which is optimal and does not use subtowers, although this is, essentially, a trivial variation of a subtower solution. We move disc 1 to peg 2, disc 2 to peg 3, disc 3 to peg 4, disc 1 to peg 4 (at this point, just before the last disc moves, one peg does not contain consecutive discs), disc 4 to peg 2, disc 1 to peg 1, disc 3 to peg 2, disc 2 to peg 2 and disc 1 to peg 2. This takes nine moves (but, of course, from the table there is also a subtower solution taking nine moves). It is also supposed that an optimal solution can be obtained by first transferring the subtower of smaller discs using four pegs and then moving the other subtower using three pegs. At the time of writing no example has been found contradicting these assumptions and the conjectures have been verified for n ≤ 30. If we accept these conjectures, a formula (of sorts!) relating the number of moves using four pegs (f(n)) to the number of discs (n) can be established. It is simplest to look first at the case where n is a triangle number. For example, consider the case of n = 10 (so n = t4, the 4th triangle number). Then, if we consider this tower of ten discs as four separate subtowers of one, two, three and four discs sitting on top of each other, with the largest number at the base, then transferring these four subtowers as whole entities using four pegs reduces to exactly the same problem as moving four discs using three pegs. So, following the algorithm for three pegs given above, with the disc numbers now referring to subtower numbers, the transfer can be completed by moving subtowers in the order 121312141213121 If the ‘subtower solution’ is optimal this will give a total (minimum) number of moves of: (1 × 15) + (2 × 7) + (22 × 3) + (23 × 1) = 49 In general, if n = tk,, then the minimum number of moves by this subtower method is given by: f(tk) = 1 × (2k - 1) + 2 × (2k-1 – 1) + 22 × (2k-2 – 1) +………+ 2k-2(22 – 1) + 2k-1(2-1) = (k × 2k) – (2k – 1) = (k – 1) 2k + 1 This analysis (splitting 10 into the sum of consecutive numbers) suggests that there is something special about the triangle numbers. They appear to represent the most efficient distribution of discs using this subtower method, which automatically satisfies recurrence relation (1) with (for n = tk) m = tk-1 and n – m = k. Moreover, the table of results suggests that, with four pegs, the number of moves increases by the same power of 2 each time before ‘jumping’ just after a triangle number. After the kth triangle number the number of moves appears to increase by 2k for every additional disc until the next triangle number. If this pattern continues then, for n = tk + r where 0 ≤ r ≤ k, f(n) = (k – 1) 2k + 1 + r × 2k = (k – 1 + r) 2k + 1 This covers all possibilities since n can be written uniquely as n = tk + r where 0 ≤ r ≤ k. We can show that this formula satisfies (1) in all cases with m = tk-1 + r (and n – m = k), as then: f(n) = 2f(m) + g(n-m) = 2f(tk-1 + r) + g(k) = 2((k – 2 + r) 2k-1 + 1) + 2k - 1 = (k – 2 + r) 2k + 2k + 1 = (k – 1 + r) 2k + 1 Since this formula holds for n = 1, this formula gives the number of moves for transferring n discs using four pegs, for any n. However, we do not yet know that this is a minimum choice for m, even using the subtower strategy leading to formula (1). To prove that M = tk-1 + r is the best choice for m using the strategy of formula (1) we use induction on n. The following argument is tricky and perhaps should not always be attempted with students! Suppose m = tj-1 + r gives a minimum number of moves, following the strategy leading to (1), for all n = tj + r < N = tk + R (with 0 ≤ r ≤ j and 0 ≤ R ≤ k). Then, let m(N) be the number of moves required by partitioning N into m and N – m (in most cases not minimal for N). Let E(m) = 2f(m) + g(n - m) – (2f(m - 1) + g(n – m + 1)) Then E(m) represents the difference between the number of moves required to transfer N discs with a partition of N into m and N – m and the number of moves required to transfer N discs with a partition of m - 1 and N – m + 1. We shall try to find when E(m) < 0, = 0 and > 0 to establish a value of m that gives the minimum number of moves. There are two cases to consider for m: (1) m = tj (2) m = tj + s where 1 ≤ s ≤ j (1) E(m) = 2f(m) + g(N - m) – (2f(m - 1) + g(N – m + 1)) = 2f(tj) + 2N-m + 1 – (f(tj-1 + j – 1) + 2N-m+1 + 1) = 2((j – 1)2j + 1) – 2((j –2 + j - 1)2j-1 + 1) + 2N-m = 2j - 2N-m (2) E(m) = 2f(m) + g(N - m) – (2f(m - 1) + g(N – m + 1)) = 2f(tj + s) + 2N-m + 1 – (f(tj + s – 1) + 2N-m+1 + 1) = 2((j – 1 + s) 2j + 1) – 2((j – 1 + s - 1) 2j + 1) + 2N-m = 2j+1 – 2N-m Now, if N = tk, then M = tk-1 (and N – M = k) When m = M, E(m) = 2k-1 - 2N-M = 2k-1 – 2k <0 m = tj + s where 0 ≤ s ≤ j and j < k - 1 When m < M, E(m) When m > M, application’!) ≤ 2j+1 – 2N-m < 2k – 2N-m < 0 since j < k - 1 since N – m > N – M = k m = tk-1 + s where 1 ≤ s ≤ k (remember: m = N is not defined as a ‘subtower E(m) = 2k – 2N-m > 0 since N – m < k Hence the (unique) value of m that minimizes f(N) is m = M = tk-1 Also, if N = tk + R (0 < R ≤ k), then M = tk-1 + R (and N – M = k) When m = M, E(m) = 2k - 2N-M = 2k – 2k = 0 (so, given the results below, there are at least two minimum values) When m < M, E(m) m = tj + s where 0 ≤ s ≤ j and j < k - 1 ≤ 2j+1 – 2N-m < 2k – 2N-m < 0 When m > M, E(m) = 2k – 2N-m > 0 since j < k - 1 since N – m > N – M = k m = tk-1 + s where R < s ≤ k – 1 or m = tk + s∕ where 0 ≤ s∕ < R or E(m) = 2k+1 – 2N-m > 0 since N – m < N – M = k Hence, again, the value of m that minimizes f(N) is m = M = tk-1 So, finally, by induction, the value of m that minimizes f(N) is m = M = tk-1 + R, with one other value (tk-1 + R – 1) when R ≠ 0. This result can be confirmed by looking at the table of values for f(n). For example, when n = 15 (t5), the minimum number of moves occurs when m = 10 (t4). So the best (known) strategy is to move 10 discs using all four pegs (taking 49 moves), then the remaining 5 using the three’ legal’ pegs (taking 31 moves), before replacing the 10 discs (taking another 49 moves). So f(15) = 49 + 31 + 49 = 129 (which is a lot better than 32767 using only three pegs). This solution is unique. However, when n = 14 (t4 + 4), there are two solutions. We can move 10 (t3 + 4) discs using four pegs then 4 using three pegs then 10 using all four. This takes 49 + 15 + 49 = 113 moves. But we could also move 9 (t3 + 4 – 1) discs using four pegs then 5 using three then 9 using four. This also takes 41 + 31 + 41 = 113 moves. There is no ‘watertight’ proof that the formula: f(n) = (k – 1 + r) 2k + 1 where n = tk + r (0 ≤ r ≤ k) always gives the minimum number of moves but this formula is correct for all applications of the (promising) strategy for moving the first m discs using four pegs then the remaining n – m using only three pegs etc. So, the four sequences: (1) 1, 2, 4, 8, 16, 31, 57, 99, 163……………….. (2) 1, 3, 4, 6, 7, 9, 10, 11, 13, 14……………….. (3) 1 2 , 5 12 , 23 60 , 307 840 , 893 2520 , 9613 27720 ............... …….. (4) 1, 3, 5, 9, 13, 17, 25, 33, 41, 49……………. relate to the above problems and should surprise all but the most mathematically gifted of students when used as ‘enrichment material’ in the classroom. They can also lead to the discussion of other problems. The ‘cake’ problem (find the maximum number of ‘slices’ (regions) obtained if a circle is divided by n cuts) arises naturally from (1). ‘Find all positive integers that can be written as the sum of distinct squares’ is a problem similar to (2). Various combinatory problems use the notation in (3) and there are many Tower of Hanoi variants associated with (4), even connected with the Sierpinski triangle! Notes for MEI session at 10.30 on Friday 27th June: John Cooper