Christopher Mowla Math 3900 November 18, 2011 The Rubik’s Cube Rubik’s Cubes of Order n • A Rubik’s Cube of order n is referred to as the nxnxn cube, where n n 1, n . • A cube with n = an even integer value is referred to as an even cube. • A cube with n = an odd integer value is referred to as an odd cube. • A cube of size n = 4 and larger are referred to as big cubes. • Other commonly solved cube sizes are: n=2 n=4 n=5 n=6 n=7 n=9 n = 11 Piece Types of the 3x3x3 Corners: They each have 3 stickers. Edges: They each have 2 stickers. (Fixed) centers: They each have 1 sticker. They are fixed on a xyz axis. Piece Types of the nxnxn • Unlike the common 3x3x3 Rubik’s Cube size, there are 4 additional types of pieces on the nxnxn cube, in general. • Therefore, there is a total of 7 different pieces types which can be seen on larger cube sizes. • Side Note: We will exclude the 1x1x1 cube size for consistency (it’s an exception in more than one respect). Types of Pieces (7) • Corners • Edges – Middle Edges – Wing Edges • Centers – Fixed Centers – Non-Fixed Centers • X-center pieces, oblique center pieces, and + center pieces. • For illustration, we will construct cube sizes up to the 7x7x7 to see all 7 of the possible piece types. – The standard 3x3x3 Rubik’s Cube does not have all of the possible piece types. – The 7x7x7 Rubik’s Cube has all of the possible piece types. • We can construct all cube sizes from the 2x2x2 cube because all cube sizes from n ù 2 have 8 corners. Constructing the nxnxn Odd Cube Size Construction 2x2x2 3x3x3 3x3x3 5x5x5 New piece types on the 5x5x5 • There are three new piece types on the 5x5x5: wing edges, X-center pieces, and + center pieces. Wing Edges • (They are commonly called wing edges by the cubing community due to their symmetry.) X-Center Pieces • They are called X-center pieces by the cubing community because they form an X about the composite center. + Center Pieces • These are called + center pieces (many refer to them as T-center pieces as well) because they form a plus sign about the big cube center. 5x5x5 7x7x7 Wing Edges • For the 7x7x7, we have a second set of 24 wing edges. • The term orbit is used to differentiate different sets of wing edges. It means where the pieces are able to move. – On the 7x7x7 cube, we have 2 orbits of wing edges. X Center Pieces + Center Pieces New piece type on the 7x7x7 Oblique Center Pieces • The term oblique is used to describe these center pieces because they are neither X-center pieces nor + center pieces. Permutations • A permutation is an arrangement of objects of the same type in some order. • Permutations can be decomposed into cycles. Definition of a Cycle • An n-cycle is moving n pieces (2 or more) of the same type (i.e. edges, corners, or centers) at the same time so that, when the algorithm generating the cycle is repeated exactly n times (and not until then), the cube will be restored to the original state it was in. Examples of N-Cycles 3-Cycles (Permutations of Middle Edges and Corners on the 3x3x3) 2-Cycles (Permutations of Wing Edges on the 5x5x5) 4-Cycles (Permutations of Wing Edges on the 5x5x5) Combinations of Disjoint Cycles • Definition: If an algorithm affects 4 or more pieces of the same type on a cube (corners, edges, or centers), all of the pieces affected need not be part of an n-cycle. • In other words, n pieces of the same type affected by an algorithm an n-cycle of pieces. 2 2-Cycles (Permutations of Middle Edges on the 3x3x3) 2 2-Cycles (Permutations of Wing Edges on the 5x5x5) 2 2-Cycles (Permutations of Wing Edges on the 5x5x5) 2 3-Cycles (Permutations of Wing Edges on the 5x5x5) Calculating the Number of Permutations (Positions) on the nxnxn Cube (for n>1) • By the multiplication rule of probability, the main idea is to determine the number of possible permutations for each piece type and multiply them all together. More Background Information Permutation Notation • Permutations are bijective maps (one to one and onto) and therefore can be represented by: 2 3 4 5 6... n 1 , f n f 1 f 2 f 3 f 4 f 5 f 6 ... where f 1 , f 2 , ..., f n are each different values of n. Classifying Permutations • A permutation can be either even or odd. – An even permutation is a permutation in which can be solved (achieve the identity) in an even number of 2-cycle swaps. • The identity is an even permutation. – An odd permutation is a permutation in which can be solved (achieve the identity) in an odd number of 2-cycle swaps. • For example, 4-cycles are odd permutations because they can be split into three connected 2-cycles. Example: 1 2 3 4 2 4 1 3 means 12, 24, 43, 31. • In order to achieve the identity (an even permutation), where each domain value is equal to its corresponding co-domain value, 1 2 3 4 1 2 3 4 We can perform the following three swaps (2-cycles) 1 2 3 2 4 1 4 2 1 2 1 2 4 21 1 2 3 4 3 1 4 2 3 3 4 4 3 1 2 3 4 e. 4 3 1 2 3 4 • On the other hand, two disjoint 4-cycles of a specific object type is an even permutation. For example, the two 4-cycle: 1 2 3 4 5 6 7 8 7 8 1 2 3 4 5 6 can be decomposed to an even number of 2-cycles: 1 71 51 31 8 2 6 2 4 • It turns out that the number of even permutations is equal to the number of odd permutations for sets of 2 or more objects. – Half of the permutations are even. – Half of the permutations are odd. • For n objects of the same type, there are n! possible permutations. Rubik’s Cube Interpretation of Permutations • Permutations on the nxnxn Rubik’s Cube mean how many possible positions there are for each piece type combined with the rest of the other types of pieces. A second meaning of the term “permutation” on Rubik’s Cubes • As with the mathematical definition of permutations, the term permutation is also used to describe the location where each piece is located. • The first row of the permutation notation can be assigned to fixed slots on a cube. For example, the slots containing the wing edges in the last layer of a 5x5x5 can correspond to the permutation notation as follows: 1 f 1 2 3 4 5 6 7 f 2 f 3 f 4 f 5 f 6 f 7 7 6 5 8 3 1 2 4 8 f 8 – Each number on the cube designates the slot number (the first row of the 2-line permutation notation) and f(1) is the wing edge piece in slot 1, f(2) is the wing edge piece in slot 2, etc. Orientation • The term orientation refers to how a particular piece type on a cube is twisted in its location. Orientation of Corners • Corners can be twisted 3 different ways, and thus have 3 orientations each independently. Orientation of Middle Edges • Edges can be oriented in two ways: flipped or not flipped. • No other piece type can have a different orientation: their movement is strictly said to be permutations (movements to different locations). • Fixed center pieces rotate in their locations, but cannot “twist.” • If a wing edge appears to be flipped, it’s the other wing edge that is in the same composite edge. The Corners • There are 8 Corners. 8! • Each corner can be oriented (twisted) in 3 ways independently. 8 8! 3 3 3 3 3 3 3 3 8! 3 Laws of the Cube (1) • Actually, by what is commonly referred to as “cube laws,” only 1/3 of the 3^8 orientations of corners are possible. • If we go back to the illustration of the three ways a corner can be twisted, • Suppose the left most image represents the identity. Then: – The corner in the left image is turned clockwise 0 times from the identity. – The corner in the middle image is turned clockwise 1 time from the identity. – The corner in the right image is turned clockwise 2 times from the identity. 0 1 2 • Once one chooses a point of reference, that is, one fixes one corner out of the 8 to be in the identity, then the sum of the values of either +90 degree twists or -90 degree twists (not both) from the identity must be evenly divisible by 3. For example, an impossible state is to have the entire cube solved except for one corner twisted, since 1 is not evenly divisible by 3. • Neither can there be two corners twisted clockwise once since 1+1 = 2, which is not evenly divisible by 3. Orange • On the other hand, you could have one corner twisted clockwise and the other twisted clockwise twice (or anti clockwise) since 1+2 = 3. Orange The Corners • There are 8 Corners. 8! • Each corner can be oriented (twisted) in 3 ways independently. 8 8! 3 3 3 3 3 3 3 3 8! 3 • Thus we divide this result by 3 to get 7 8! 3 Even Cube Symmetry • On even cubes, we can always fix a corner to be solved (in the identity) and eliminate the number of permutations it contributes to the whole. – This is because on even cubes, there are no fixed centers and therefore there is no unique way to set the cube on a table, when considering all possible ways it can be scrambled. – Since each corner can be placed in 8 different locations and twisted in 3 different ways, we divide the total number of corner permutations by to have a value of zero for odd n1 mod 2 24 values of n. Corners Conclusion • Therefore, the total number of possible permutations of corners on the nxnxn cube, taking into account the cube law and even cube symmetry is: 8 8! 3 n1 mod 2 3 3 8 7 8! 3 n1 mod 2 24 Middle Edges (Odd Cubes Only) • There are 12 middle edges. 12! • Each edge can be flipped in two ways independently. 12 12! 2 Laws of the Cube (2) • Similar to the reduction of the possible orientations of the corners, by the “cube laws,” only 1/2 of the 2^12 orientations of middle edges are possible. • Only an even number of middle edges can be flipped. Middle Edges (Odd Cubes Only) • There are 12 middle edges. 12! • Each edge can be flipped in two ways independently. 12 12! 2 • By the “cube law,” we divide this number by 2 to have 12 12! 2 2 11 12! 2 Laws of the Cube (3) • It also turns out that the middle edges are in an odd permutation if and only if the corners are in an odd permutation. • Recall that odd permutations make up half of all permutations of 3 or more objects. • Since half of the permutations of two different piece types are dependent on each other, only half of the permutations of one of them is allowed on the cube. Middle Edges Final • Since middle edges only are in odd cubes (and thus the presence of both the corners and middle edges only occurs on odd cubes to cause the ½ reduction), we divide what we had previously by 2 and raise it n mod 2 to have a value of zero for even cubes. 11 n mod 2 12! 2 2 10 n mod 2 12! 2 Wing Edges • Whether even or odd cube sizes, big cube sizes (larger than the 3x3x3) have n 2 2 sets (orbits) of 24 wing edges. • For example, the 6x6x6 has 6 2 4 2 2 2 2 orbits of wing edges. • The 7x7x7 has 7 2 5 2 2 2.5 2 orbits of wing edges. n 2 2 • Since there are orbits of wing edges on the nxnxn cube, containing 24 wing edges each, the total number of permutations of the wing edges is: n 2 2 24! . X-Center Pieces, + Center pieces, and Oblique Center Pieces. • Similar to wing edges, big cubes have a set number of orbits of all non-fixed center pieces. • To determine the number of orbits for the nxnxn, let’s observe a large big cube center. • Suppose we are looking head on at the white face of a 13x13x13. Let’s shade in the fixed center piece (not part of the nonfixed center piece calculation), the corners, and all orbits of wing edges. • Now, imagine we were going to divide this composite center into 4 pieces. • If this was an even cube, then we could divide the composite center into 4 equal squares, but as an odd cube, this is the best we can do with an extra slice row and column in the center. • The reason we are dividing the center into 4 equal parts it for us to imagine that we are turning the face (outer most slice) closest to us. Turning the face in either direction will send all of the purple pieces in each quadrant to the other 3 quadrants after three rotations. • Recall that the term “orbit” refers to where pieces can move to. • Therefore, since all 4 quadrants can move to each other, we need only consider one quadrant to count the number of orbits of non-fixed center pieces. • Clearly for even cube sizes, the number of non-fixed center orbits is the amount of squares in each quadrant: 2 n2 . 2 • For odd cubes, notice that the white cross also consists of 4 symmetrically equivalent blocks. If we rotate the face 3 times, all of these n3 blocks will go to each 2 other. • (These blocks make up the orbits of the + center pieces.) • Therefore for odd cubes, the total number of non-fixed center orbits is: n 3 n 3 n 1 n 3 2 4 2 2 • However, we can also just take the floor function of the even cube number to obtain an equivalent value: n 2 2 2 • Note that there are 4 of each non-fixed center piece type (since we divided the composite center into 4 equal parts) in every one of the 6 faces of the cube, or 4(6) = 24 non-fixed center pieces in each orbit. • This gives the total number of possible permutations of non-fixed center pieces on odd and even cubes to be: n 2 2 2 24! . Non-Fixed Centers Final • Lastly, just as there were 4 pieces of each type in each face. – Each face is a different color. – Non-fixed center pieces are indistinguishable. – Therefore, we must divide by: n 2 2 2 1 6 4! • This gives us a final number of: n 2 2 24! 2 . 6 4! The Formula • Multiplying the total number of permutations for the corners, middle edges, wing edges, and non-fixed center pieces all together, we achieve the formula for the number of positions of the nxnxn Rubik’s Cube. F n 7 8! 3 n 1 mod 2 24 12! 2 10 n mod 2 n2 2 24! n 2 2 24! 2 6 4! Examples • • • • • • n =2: 3,674,160 n = 3: 43, 252, 003, 274, 489, 856, 000. n = 4: Approximately 7.40 x 10 ^45. n = 7: Approximately 1.95 x 10^160. n = 11: Approximately 1.09 x 10^425. n = 100: Approximately 2.35 x 10^ 38, 415 Supercubes • Probably everyone has either seen or heard of the Sudoku 3x3x3 cube: Supercubes • Notice that the numbers of the center pieces are all turned to match the direction of the numbers on the corners and middle edges perfectly. Definition • An nxnxn supercube is similar to the nxnxn cube, except that all center piece types, both the fixed center pieces and the 3 non-fixed center pieces types (X-center pieces, + center pieces, and oblique center pieces) are distinguishable. • In other words, the regular 6-colored nxnxn cube and the nxnxn supercube have the same number of permutations for the “Cage” portion of the cube. • Since the 2x2x2 does not even have centers, the supercube sizes begin with n = 3. • Supercubes have more permutations than regular 6-colored cubes. Calculating the Number of Positions of the nxnxn supercube. • We merely need to multiply the formula for the regular nxnxn by a factor determined by the additional number of ways each color of center pieces can swap with each other (in any permutation from the formula for the regular 6-colored nxnxn cube). Fixed Centers (Odd Cubes Only) • There are 6 fixed centers on every odd cube. • Each center can be rotated in 4 directions in its location. 6 n mod 2 • This gives total permutations. 4 Laws of the Cube (4) • Just as the middle edges are in an odd permutation if and only if the corners are in an odd permutation, it carries on to fixed centers as well. • That is, middle edges, corners, and fixed center pieces are all dependent on each other. If one of them has an odd permutation (or even permutation), so do the other two. Fixed Centers (Odd Cubes Only) • There are 6 fixed centers on every odd cube. • Each center can be rotated in 4 directions in its location. n mod 2 6 • This gives 4 total permutations. • By the “cube law,” we divide this number by 2, because only half of the fixed center permutations are allowed: 4 2 6 n mod 2 Non-Fixed Center Pieces • From calculating the formula for the regular nxnxn, we found that there are: n 2 2 2 orbits of non-fixed center pieces. • In each orbit, there were 24/6 = 4 center pieces of each color. • Now that center pieces ARE distinguishable, we have an additional 4! permutations of each color. There are 6 colors, which gives us 4! 6 • We raise this to the number of orbits of non-fixed centers, since that is the number of different sets we are multiplying together: n2 2 6 2 4! n2 2 6 2 4! Laws of the Cube (5) • Now that non-fixed center pieces are unique to their positions, – An odd permutation of wing edges exists if and only if an odd permutation exists in the + center pieces and oblique center pieces. – An odd permutation of corners exists if and only if there is an odd permutation all of the Xcenter pieces n 2 2 n 2 1 n 2 2 and at least 2 2 2 2 + center and oblique center pieces. • Despite the complexity of these relationships, the total number of permutations shared between the non-fixed center pieces and the corners and wing edges is just: 2 n 2 2 2 • Therefore, we divide by this amount: 1 n 2 2 2 2 , which means we only consider half of the permutations of each orbit of non-fixed centers. The Formula for the Supercube • We multiply the formula for the regular 6colored nxnxn by all of the factors just discussed to achieve the formula for the supercube: 46 S n F n 2 4 S n F n 2 6 n mod 2 n mod 2 n 2 2 6 2 4! 2 n 2 2 6 2 4! 2 n 2 2 1 2 The Factor Increase (Examples) • The number of permutations of the regular nxnxn are increased by: • n = 2: 1 • n = 3: 2,048. • n = 4: 95, 551, 488. • n = 7: Approx. 1.56 x 10 ^ 51. • n = 11: Approx. 8.24 x 10 ^ 162. • n = 100: Approx. 3.55 x 10 ^ 19, 160. Relationship Between Wing Edges and Non-Fixed Center Pieces. • We need to find a formula to represent the total number of non-fixed center orbits in an odd permutation for a given number of orbits of wings in an odd permutation. • We will use a 13x13x13. • As mentioned earlier, a 4-cycle is an odd permutation and two 4-cycles is an even permutation. • In fact, if we do a quarter turn to an inner layer slice of the cube, we can model it. • These are the X-center pieces • If we reflect this now to the top, clearly (n-2)-2 center orbits in an odd permutation now in the yellow column (just focus on the yellow column, not its corresponding yellow row). • Reflecting this to the top, clearly we have (n-2)-2-2 center orbits left with an odd permutation in both slices. That is, 2(n-2-2(2)). • We now have exactly (13-2)-2-2-2=5 NF center orbits in an odd permutation in each wing edge orbit we chose. • Clearly there is a pattern and if we were to choose arbitrary wing edge orbits, the number of non-fixed center orbits in an odd permutation with the wings would be the same for any combination of the same number of wing edge orbits. • The formula is: w n 2 2w w n 2 2w 2 Example • On the 1,000 x 1,000 x 1,000 cube, if w = 65 orbits of wings have an odd permutation, then 65 1, 000 2 2 65 56, 420 2 orbits of non-fixed center orbits (consisting of + and oblique centers) has an odd permutation. The Maximum Formula • It’s useful for us to know the maximum number of non-fixed center orbits that can be in an odd permutation for a given size n. Finding a Maximum Formula By the Use of Calculus • The formula w n 2 2w variable function because 2 is NOT a 2 n 2 1 w In 2 Thus, the maximum value for a given n is the maximum value achieved by at least one w from that domain. • We can differentiate with respect to w, since that is the changing domain: 2 w n 2 2w n 2 4w w • To verify that we will obtain the maximum value, we differentiate once more. n 2 4w 4 0 w I n w • Setting the first derivative equal to zero to find the critical point, we have: • By comparing the formula to the true maximum values, we just need to n2 n 2 4w 0 w take the floor of this. 4 • Substituting w into w n 2 2w , we get 1n2 2 2 2 2 1 n 2 2 2 2 • We can see a 3-D graph representation of the formula w n 2 2w 2 very well by rewriting as . 2 w n 2 2 w n W • The graph of the maximum formula 1 n 2 2 M n 2 2 w w n 2 2 w 2 n • Instead of resorting to the floor function, we can determine whether or not there is a unique value of w to yield the maximum value for cubes of size n. • Comparing the formula derived from calculus with the actual maximum values, 1n2 2 2 2 1) If n is odd, then we have 1/8 more than necessary. 2) If n is even and evenly divisible by 4, then we have 1/2 more than necessary. • We can use trig functions instead. 1 n 2 1 2 n 1 2 n 2 n sin cos cos 2 2 8 2 2 4 2 2 • But also note that: 1 n 2 n 2 n 4n 4 2 2 8 8 2 2 2 n n 4n 3 cos n 1 n 3 1 2 n 2 cos 8 8 8 2 • We no longer need to subtract 1/8 for odd cubes because we multiplied 1/8 by cosine. 2 2 n 1 n 3 1 cos2 n 1 cos2 n cos2 n 8 8 2 2 4 2 n 1 n 3 , if n is odd, 8 n 1 n 3 3 M n , if n is divisible by 4, 8 8 n 1 n 3 1 , if n is even, but not divisible by 4. 8 8 Solutions for Even Cubes Divisible by 4 n 1 n 3 k 2 solve w n 2 w , w for k 3 8 8 • Using the quadratic formula, we get: n n w1 1, w2 2 2 • Both solutions work! Therefore w is not unique for this cube size class. Solutions for Even Cubes Not Divisible by 4 n 1 n 3 k 2 solve w n 2 w , w for k 1 8 8 • Using the quadratic formula, we get: n2 w1 w2 (double root) 4 • This is equal to the critical point we found, which is not surprising since the original formula worked for this cube class from the start. Solutions for Odd Cubes n 1 n 3 k 2 solve w n 2 w , w for k 0 8 8 • Using the quadratic formula, n 1 n3 w1 , w2 4 4 – w1 is true for every other odd integer starting with n = 5. – w2 is true for every other odd integer starting with n = 7. Issues • We do not have a single representation for the value of w that yields the maximum value. • If we approach this problem using the following 4th order non-homogeneous recursion relation ak 3 ak 7 2 k 4 , k 8 with the initial conditions: a1 0, a2 2, a3 4, and a4 6 • With ingenuity, we can find the solution: n 4 2 n n 2 n 4i 2 n 2 2 4 4 i 1 • Comparing with the original formula w n 2 w2 n • Clearly w 2 4 , and we can represent w equal to that for all size cubes. However, we note that n evenly divisible by 4 has two solutions: w n 1, n . 2 2 Relationship between the non-fixed centers and the Corners • Since we found the formula 1 n 2 2 M n 2 2 using calculus, we can resume the following slide: Laws of the Cube (5) • Now that non-fixed center pieces are unique to their positions, – An odd permutation of wing edges exists if and only if an odd permutation exists in the + center pieces and oblique center pieces. – An odd permutation of corners exists if and only if there is an odd permutation all of the Xcenter pieces n 2 2 n 2 1 n 2 2 and at least 2 2 2 2 + center and oblique center pieces. • As we first were deriving w n 2 2w , we learned that the X-center pieces were in a 2 4-cycle when inner layer slices were turned. Hence we should be able to understand the first bullet completely. • The second bullet is merely stating that Xcenter pieces are in an odd permutation if the corners are in an odd permutation. • We can see this using a similar image as before, just extrapolating the permutation to the outer layer. 2 • If a quarter turn of the outer most layer is done in the same direction as on the 13x13x13 example, then the corners are in following 4-cycle (odd permutation). • In addition, the X-center pieces are in a 4cycle (odd permutation) too. • The only item left to interpret in the second bullet is: n 2 2 n 2 1 n 2 2 2 2 2 2 • The total non-fixed center pieces (besides Xcenter orbits which is equal to n 2 2 can be no less than the total number of nonfixed center orbits minus the maximum number of center orbits which can be in an odd permutation with wings, M(n). References • Cube Laws http://www.ryanheise.com/cube/cube_laws .html • Number of Permutations http://en.wikipedia.org/wiki/Rubik%27s_cu be