Category: Uncategorized

  • Optimizing settings

    Let’s say you’re making some sort of program with options, and it’s possible to turn on option A or option B, but not both. You could just leave them as two settings and disable one if the other is on, or you could turn them into one setting with three choices: off, A, B.

    However, if there are three independent options, it’s better to leave it as three separate settings rather than one setting with eight choices.

    What if the three options can’t be turned on all at once but are otherwise independent? I’d say that three settings that just can’t be all turned on at once is best.

    A somewhat more formal statement of the general problem:

    We have a set of Boolean variables {A,B,…} (options) and some constraint that they have to satisfy.
    Each setting controls one or more options, but no option can be controlled by multiple settings.
    Each setting has all possibilities for its relevant options available, but no more.
    The valid combinations are connected via changing one setting at a time.

    I haven’t figured out what exactly should be optimized for, but I know it should follow a few obvious rules:

    • Rearranging the options preserves the optimal solution
    • Swapping any option’s off with its on preserves the optimal solution
    • Taking the disjoint union of two different sets of options and taking the Cartesian product (logical AND) of their constraints yields an optimal solution that is the disjoint union of the two original optimal solutions.
    • If a solution is optimal and you can add another possibility to the constraint and have it still be a valid solution, the resulting solution is still optimal.

    Let’s say our constraint is (A AND B) OR C. I’d say the optimal solution is one setting for A and C and another for B, or one setting for B and C and another for A.
    If our constraint is A XOR B XOR C, it’s forced to be one setting for all three, because I’m not able to represent “One setting each for A and B, and C is whatever it has to be to work” in this system.
    What if our constraint is C IMPLIES B AND B IMPLIES A? It seems pretty obvious to me that the answer is just one setting for all three. (If you think about it, this is how difficulty levels in certain games work)
    However, for the constraint (A XOR B) OR (A AND B AND C), I feel like there should be one setting for A and B and one setting for C.

    I could keep listing examples of various constraints and what I feel like should be the optimal solution, but I think I should stop there. It seems to me that my criteria for an optimal solution is: “Never have two settings that can only change when the other is in a specific state, and of those possibilities, minimize the maximum number of choices for each setting.”

  • Life in a four-dimensional universe

    There are a number of differences between four-dimensional space and three-dimensional space. This article will go through those differences and how they may affect 4D life.

    Space grows like x^4 instead of x^3

    Seeing lights from afar would be more difficult, as the sphere of directions is now 3D.

    Diameters of different sized objects tend to be much closer, which is an effect that perfectly cancels out with more efficient packing of objects of the same diameter.

    You may think objects of the same size would have more surface area, but if you compensate for the different dimensionality (surface volume ^ 2/3 vs surface area), cubes of the same volume have less surface area in 4D.

    1D objects can no longer be tangled

    Earphones in pockets and electrical wiring no longer get accidentally tangled, but knots in rope have to rely purely on friction.

    Flat surfaces are now 3D instead of 2D

    Let’s subdivide this section into several more sections based on the differences between 3D and 2D:

    Space grows like x^3 instead of x^2

    Cities can expand out more easily, with a smaller diameter relative to building size. Buildings in general also decrease in diameter due to floorspace increasing relative to smaller diameters.

    1D objects can cross over each other

    It’s possible to connect five places with roads without needing any intersections aside from those places. This also means that maps can require arbitrarily many colors instead of just 4.

    Trains are no longer forced to cross over other roads.

    Flat surfaces are now 2D instead of 1D

    Boundaries between countries would now be 2D rather than 1D, making them much harder to defend.

    The space of sideways directions can now be rotated through. This rotation is called twirl, and it actually deserves a major section of its own.

    Twirl

    Mixing up left and right (and the new sideways directions) is way more common. I’m pretty sure they wouldn’t even have specific names for sideways directions.

    The convention for writing text would have to be changed. Maybe each line is a spiral spiraling outward?

    You can no longer rely on muscle memory to locate things unless you twirl yourself into a consistent orientation beforehand.

  • Unintuitive examples of non-transitivity

    A transitive relation is a relation r where if A r B and B r C, then A r C. A non-transitive relation is any relation that isn’t transitive.

    The most famous example is rock-paper-scissors: rock beats scissors, scissors beats paper, but rock doesn’t beat paper. However, there are other ways to make nontransitive relations.

    All of the examples I’ll give in this article will be shown non-transitive by finding a basic rock-paper-scissors cycle in an antisymmetric relation.

    It’s possible to make three random variables such that A > B, B > C, and C > A, each with over 60% probability: Set A to 3, B to 61% 2 and 39% 5, and C to 61% 4 and 39% 1. A 4-cycle can allow for the winning probability to be 2 in 3. It is impossible for the winning probability in any cycle to be larger than 75% if the variables are uncorrelated (Past 75%, each one has to have a lower median than the previous, which can’t happen in a cycle). If the variables are correlated, the probability can be arbitrarily large (To get 99%, you need 100 variables.)

    Now, consider the functions f(x) = 3+3*round(x/3), g(x) = f(x+1)-1, and h(x) = f(x+2)-2. For any x, f(g(x)) > g(f(x)), g(h(x)) > h(g(x)), and h(f(x)) > f(h(x)). This means that comparing functions by which application order makes the result greater is a non-transitive relation.

    Now for a non-theoretical place where non-transitivity shows up:
    Say you’re hosting a vote for which of three things to use, and people submit their votes as rankings of the three things. It turns out that it’s possible for the majority rule on individual pairs to lead to a non-transitive relation, e.g. if the votes are A > B > C, B > C > A, and C > A > B, then A > B, B > C, and C > A all appear in 2/3 the votes. This is called the Condorcet paradox.

  • 3 + 40 = 4 + 15 + 24

    Replace every number in the above equation with its reciprocal and the equation is still true. Any equation using the four basic operations that has this property can be rewritten as an equality of two sums that still has this property by using the distributive properties of multiplication and division, applying the multiplications and divisions, and moving subtractions to the other side. (e.g. 3 + 4*(10 – 1) = 30/2 + 24 -> 3 + 4*10 – 4 = 30/2 + 24 -> 3 + 40 – 4 = 15 + 24 -> 3 + 40 = 4 + 15 + 24)

    Equations of the form a + b = x + y + z are the simplest possibility that exists non-trivially in the real numbers, and I have found several such equations.

    Multiplying all the numbers in the equation by the same number will preserve the property. This scale invariance means that these equations can be put into equivalence classes by scaling. The equivalence class including a + b = x + y + z will be denoted as (a,b|x,y,z). For convenience, I will write numbers on each side in ascending order.

    The first six equivalence classes I found that fit within the integers are (3,40|4,15,24), (3,40|5,8,30), (5,45|8,15,24), (8,72|15,24,45), (5,56|7,24,30), and (15,168|28,35,120). There is a simple involution that is very important: (a,b|x,y,z) -> (1/b,1/a|1/z,1/y,1/x).

    The way I generate new solutions is quite simple:
    Generate three random somewhat-composite numbers1 to go on the right side, then use the formulas S = a + b + c and P = Sabc/(ab+ac+bc) to determine the sum and product of the two numbers on the left side, then (S/2)+-sqrt((S/2)^2-P) to determine the two numbers on the left. Then I have the computer do this over and over until the results are integers or half-integers.

    After performing the above search for around an hour, I have come across the solutions (15,760|19,72,684), (55,561|80,264,272), and (48,364|105,112,195).

    You may notice that that’s not a particularly useful way of writing these. I’ll write them in prime factorization instead: (3*5, 2*2*2*5*19 | 19, 2*2*2*3*3, 2*2*3*3*19), (5*11, 3*11*17 | 2*2*2*2*5, 2*2*2*3*11, 2*2*2*2*17), and (2*2*2*2*3,2*2*7*13|3*5*7,2*2*2*2*7,3*5*13).
    This lets us find their duals in integer form easily – the first has a LCM of 2*2*2*3*3*5*19, the second has an LCM of 2*2*2*2*3*5*11*17, and the third has an LCM of 2*2*2*2*3*5*7*13.
    Therefore, their duals are (3*3, 2*2*2*3*19 | 2*5, 5*19, 2*2*2*3*3*5), (2*2*2*2*5, 2*2*2*2*3*17 | 3*5*11, 2*5*17, 3*11*17), and (2*2*3*5,5*7*13|2*2*2*2*7,3*5*13,2*2*2*2*13), which can be written in standard decimal notation as (9,456|10,95,360), (80,816|165,170,561), and (60,455|112,195,208). I also previously found (75,550|152,209,264) (dual: (228,1672|475,600,825)) earlier.

    Consider a prime p, and consider the five numbers’ p-adic valuations. Because p-adic valuations are preserved by negation, we can move all the numbers to one side of the bar (e.g. (|-40,-3,4,15,24)).
    Now the left side sum’s p-adic valuation is 0 (because the empty sum equals 0). The only way for the sum of two numbers to have a smaller p-adic valuation than either of them is if the two numbers have equal p-adic valuation, so the smallest p-adic valuation in the sum must occur at least twice. Applying this logic to the dual means that the largest p-adic valuation in the sum must also occur at least twice.

    If all the p-adic valuations are equal, then you can divide all the numbers by a power of p and get a solution in the integers mod p. For example, the title equation corresponds to (3,5|4,12,3) mod 7, or (3,7|4,4,2) mod 11. I haven’t found any that reduce to (1,1|1,2,2) mod 3 or (1,1|4,4,4) mod 5, despite those being valid in the fields of integers mod 3 and 5. There are none in the field of integers mod 2.

    Here’s a proof that there are no self-dual solutions in the rational numbers:
    For the sake of contradiction, assume there is such a solution. Then it can be scaled so that the middle of the right side is 1, so it’s: (a/b, b/a|c/d, 1, d/c). This means that a/b + b/a = c/d + 1 + d/c. Then, do the following algebra:

    • a/b + b/a = c/d + 1 + d/c
    • (a^2+b^2)/ab = (c^2+d^2)/cd + 1
    • (a^2+b^2)/ab – (c^2+d^2)/cd = 1
    • Note that ab and cd must be equal because of how fractions work
    • (a^2+b^2)-(c^2+d^2) = ab = cd
    • (a-c)(a+c)-(b-d)(b+d) = (a-d)(a+d)-(b-c)(b+c) = ab = cd

    If the value of each side of that final expression is odd, then a, b, c, and d are all odd, but then the first two parts would be even – even = even.
    However, if the value of each side of that final expression is even, then one of a and b is even and one of c and d is even. Because a/b and c/d were fractions written in simplest form, only one of a and b is even and only one of c and d is even. Then one of the first two expressions would be… Huh, I thought it would be odd. I guess this isn’t a complete proof after all.

    I have not found any way to generate all of these deterministically like Pythagorean triples can. Further research on this topic is needed.

    1. The way I did this was by taking the LCM of two random numbers from 1 to 100. ↩︎
    2. You may notice that this number appears to be less than the previous number. However, this is actually the number 1 in the integers mod 7, and the integers mod 7 does not have an ordering. ↩︎

  • Almost-associative Latin squares

    A group can be interpreted as a set with an associative operation whose Cayley table is a Latin square, as seen in the secret Simon Tatham puzzle called Group. (Ignore infinite groups for now.)

    What if we only want it to be almost associative, i.e. as associative as possible without actually being associative?

    I claim that any non-associative bibijective1 operation ○ must have at least eight non-associative triples. The proof is as follows:

    For any B and C, the functions x -> x ○ (B ○ C) and (x ○ B) ○ C are both bijective, so they must differ in at least two inputs. Therefore, for any A, B, and C such that A ○ (B ○ C) is unequal to (A ○ B) ○ C, there must be some other choice of A that does so. A similar line of reasoning proves that there is some other choice of B that does so, and some other choice of C that does so.

    That means that for any non-associative triple, for any of its elements, there’s a different value that still makes it non-associative. Therefore, there are at least two different possible values for the first value in a non-associative triple, and for each of them there are at least two possible values for the second value, and similarly for the third, making at least 2 * 2 * 2 = 8 non-associative triples.

    Now, an example of an almost-associative operation:

    A1A2B1B2
    A1A1A2B1B2
    A2A2A1B2B1
    B1B2B1A1A2
    B2B1B2A2A1

    Notice how it differs from the Klein 4-group in the bottom left 2 by 2, which is A ○ B. For a triple to be non-associative, it has to involve a different parity of such pairs in the two calculation orders. It can be checked that A ○ A ○ B is the only such case, and thus that it and eight equivalent triples are the only non-associative triples of ○.

    1. The first “bi” prefix in this word is used in the same sense as the word “bilinear”. ↩︎
  • The exceptional outer automorphism of S6

    Consider the complete graph on 6 vertices. There are, up to color permutation, 6 ways of coloring its edges in 5 colors such that each vertex has exactly one edge of each color, one of which is shown below:

    It turns out that every permutation of the 6 vertices permutes the 6 edge-colorings in a unique way, leading to an isomorphism between the group of permutations of the 6 vertices and the group of permutations of the edge-colorings.

    These groups are, of course, both S6. Rotating the above image by 60 degrees maps every vertex to a different vertex but it maps the shown coloring to itself, meaning that this isomorphism from S6 to S6 is not just a relabeling of the six objects. This means that it is an outer automorphism.

    A much more elegant construction of the exceptional outer automorphism of S6 involves this arrangement of the numbers 1 to 6:

    The single swap of 6 and another element X is mapped to a triple swap that includes the swap of 6 and X, as well as two other swaps between the pairs of elements equally far away from X around the circle. For example, the swap (16) maps to the triple-swap (16)(25)(34). All permutations of six objects can be generated by swaps of the form (X6), and it can be confirmed that all equations involving said swaps are preserved.

  • Numbering systems that get more cursed

    We traditionally use a base-10 numbering system. There are the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, and after 9 we reset back to 0 and count the number of resets to the left. As an example sequence to demonstrate the numeral systems, I will use the OEIS sequence A000055, starting at the final 1: 1, 2, 3, 6, 11, 23, 47, 106, 235.

    Another famous numbering system is base 12, which has two new digits for the values 10 and 11. I’ll use X and E, but they aren’t standardized across places. Some say that it’s better than base 10, but it really isn’t. The sequence is now 1, 2, 3, 6, E, 1E, 3E, 8X, 177.

    Bijective base 10 is a numbering system that is similar to ordinary base 10, but instead of a digit A for 0 it has a single digit for 10. Expressions aren’t unique if we allow for decimals to terminate at different lengths due to the implied 0s at the end (e.g. 2 = 1.A = 1.9A = 1.99A = 1.999A). Again, the sequence: 1, 2, 3, 6, 11, 23, 47, A6, 235.

    Binary is just base 2. Two is the smallest possible base that actually works. Multiplication can be done with fewer carries, due to any product of digits being also a digit. The numbers do get very long, however that can be mitigated by just using narrow characters for the digits, such as . and |. The sequence: | |. || ||. |.|| |.||| |.|||| ||.|.|. |||.|.||

    A mixed radix system is a numbering system where the base is different in each digit. For example, alternating between 6 and 10 gives us the system used by clocks (at least at the seconds/minutes level). (1, 2, 3, 6, 11, 23, 47, 1:46, 3:55).

    Roman numerals are kinda just a base 10 system but the digits’ representations are sorta additive but also have subtraction and the digits have different representations depending on which place they appear. It’s also (by some definitions) limited to a maximum of 3999, although you could also allow it to have an unlimited amount of Ms at the start, which makes for a very interesting puzzle: What happens if you sort all possible Roman numerals in alphabetical order? Anyway, the sequence: I, II, III, XI, XXIII, XLVII, CVI, CCXXXV.

    Balanced Ternary is like base 3, but it has a digit T for -1 instead of 2. It allows you to write negatives without a negative sign (e.g. -100T1T = T001T1) and do multiplication with very few carries. However, because it has 3 digits, the digits can’t be made as narrow as binary digits. Of course, the sequence: 1, 1T, 10, 1T0, 11T, 10TT, 1T1T, 11T1, 100T01.

    Base phi makes each place value phi times the previous. For example, 2 is written as 10.01 in base phi, because 2 = phi + 1/phi^2, and 3 is written as 100.01 for a similar reason. Note that writing “11” anywhere is forbidden, because 1 + phi = phi^2. I’m not doing the sequence because decimal-to-phinary conversion is a bit difficult.

    Factoradic is a numbering system where each place counts successively larger factorials. It does require infinitely many digits, but the rate at which it requires them isn’t very fast. And the sequence: 1, 10, 11, 100, 121, 321, 1321, 4120, 14301.

    Base 1.5…? In this numbering system, you have digits 0, H, and 1, where H represents one-half. So, for example, 8 is 1H0HH: 1.5^4 + 0.5*1.5^3 + 0*1.5^2 + 0.5*1.5 + 0.5 = 8. This makes numbers even longer than binary. So, the sequence: 1, 1H, 1H0, 1H10, 1H11H, 1H1010H, 1H0HH1H1H, 1H0HH1H0111, 1H0HH1H010H01. I hope I didn’t make any mistakes there.

    Bijective Unary. Only one symbol, and you just write it that many times. It’s really easy to add numbers, at the cost of only being able to represent natural numbers. The sequence: 1, 11, 111, 111111, 11111111111, 11111111111111111111111, 11111111111111111111111111111111111111111111111, 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111, 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.

    The fundamental theorem of arithmetic states that every natural number can be factorized into primes in only one way, up to ordering. So, if we just assign each prime a symbol, we can make a system where multiplication is really easy, at the cost of addition being very difficult. It also requires infinite symbols. Again, the sequence: , 2, 3, 23, E, V, G, 2L, 5G.

    We could make the above two infinite-digit-requiring notations just call themself when indexing a digit, so that only finitely many digits are needed. So, e.g. the factoradic sequence would be 1, 10, 11, 100, 1(10)1, (11)(10)1, 1(11)(10)1, ((10)0)1(10)0, 1((10)0)(11)01. The prime factorization version could have the x’th prime be written using a digit that represents x, so the sequence there would be , (), (()), ()(()), (((()))), ((())(())), ((())((()))), ()(()()()()), ((()))((())((()))).

    Another based on prime factorization: The x’th space represents the x’th prime, 0 is 0, and you can place a – before the whole thing to make it negative. So -[0][[0]] = -3, and [[-[0]]] = sqrt(2). This can represent many important numbers (even irrationals), with the slight downside that addition might not be always possible. I don’t want to do the sequence for this one, because that’d completely skip over the cursed part

    What if we want a system that can write any rational number in its range in finitely many digits, but can only write numbers in the range [0,1)? Try Reverse-Factoradic, where each decimal place counts the next reverse factorial. You could glue this system to ordinary factoradic to allow for writing all reals. Instead of the standard sequence I’ve used for the rest of these, I’ll use the reciprocal integers from 1/2 to 1/7: .1, .02, .012, .0104, .01, .003206.

    Here’s a similar system to the above: The nth decimal place represents 1/n, but the maximum of each place is 1. For example, 1 is written as 1, 2 can be written as 1.11001, and 3 can be written as 1.11111011100001001010001. I’m not doing the ordinary sequence here because integers get exponentially long. Multiplication in this one still sorta works with few carries (e.g. 1.1 * 1.01 = 1.11001), but any time two of the 1s land on each other, they create even more 1s, which can quickly cause a chain reaction if we aren’t careful.

    At this point, we may as well just give every number its own symbol. This system takes the least space of all these systems, with the slight downside that there are no patterns in the operations at all and this font doesn’t have every symbol. Again, the sequence: 1, 2, 3, 6, E, V, G, Ü, Ǯ.

  • Tic-Tac-Toe variants

    Ordinary Tic-Tac-Toe has 9 spaces and 8 lines. It’s been played for a while, and you probably already know the optimal strategy for it. This post will go through a few Tic-Tac-Toe variants.

    The Fano plane has 7 spaces and 7 lines. It’s not a very good variant, because if the first player blocks the second player’s lines at all, the first player wins. The same applies to a 3 by 3 torus (9 spaces, 12 lines).

    Next, an infinitely large variant. Spaces are integers, and lines are sets of three that add to zero. This one actually has some interesting strategy, and I called it The Zero Game. (Infinite spaces, infinite lines.)

    What if we were to base the layout on the lines? How about 4 lines, and each pair of lines has one space that precisely those lines go through, totaling 6 spaces? That turns out to only be ties as well.

    We’ve also got a few with longer line lengths: for length 4 we have the 4 by 4 torus (16 spaces, 16 lines) which is pretty balanced, as well as the finite projective plane of order 3 (13 spaces, 13 lines). For length 5 there’s Torus Games’s implementation of Gomoku (36 spaces, 144 lines), and regular Gomoku (Infinite spaces, Infinite lines).

    Here are a few more gimmicky ones that don’t really fit into the established system above, of which I invented two:
    Tic-Tac-Veto – On your turn, you pick two of your possible moves and your opponent picks which one happens.
    Politic-Tac-Toe – There are three players, the board is 5 by 5, the lines are 5 long (including diagonals!), and wins are shared by two players if a line fills up with only those two players’ symbols.
    HeXO – Infinite hexagonal grid, 6-in-a-row wins, every turn after the first lets you place two of your symbol.

  • A universe without the number two

    How would that work? For starters, there are no even numbers and addition is a ternary operation. So the natural numbers here are 1, 3, 5, 7, and so on.

    There are five basic operations: addition (5 + 3 + 1 = 9), subtraction (5 – 3 – 1 = 1), middle (5 + 3 – 1 = 7, or 5 – 3 + 1 = 3. There are multiple ways of writing it.), multiplication (5 * 3 = 15), and division (51 / 3 = 17). Note that subtraction and middle could also be written using negative numbers.

    A big issue you may notice is that we can’t just pick an arbitrary predicate and count how many numbers satisfy it. This could probably be fixed with ternary logic, but I’ll just ignore it and move in a different direction:

    Adjusting the field axioms to this type of number system (we will call them threelds), we get:
    1) a + b + c = a + c + b = c + a + b. (Commutativity of addition)
    3) a + -a + b = b (Inverse of addition)
    5) a + b + (c + d + e) = a + (b + c + d) + e = (a + b + c) + d + e (Associativity of addition)
    7) 1 * x = x (Identity)
    9) x * y = y * x (Commutativity of multiplication)
    11) x * (y * z) = (x * y) * z (Associativity of multiplication)
    13) (a + b + c) * x = a * x + b * x + c * x (Distributivity)
    15) x * 1/x = 1. (Inverse of multiplication. Note that this applies to all numbers due to the nonexistence of zero.)

    Here’s a proof that the only threeld of odd size is the threeld of order 1:
    Because of the commutativity and associativity of addition, the sum of all elements in a set makes sense if that set has an odd size.
    Consider the sum S of the set of all elements in the threeld. Multiplication is a group, and thus multiplication by any element permutes them. Thus, S is preserved when multiplying by any element. That is, for any elements a and b, a * S = b * S. Dividing by S on both sides, we get that a = b for any elements a and b, and thus that there is only one element.

  • Situations where expected value doesn’t work

    Consider a lottery where you have a 1 in 2 chance of winning $2, a 1 in 4 chance of winning $4, a 1 in 8 chance of winning $8, and so on. The expected value of this is $(2/2 + 4/4 + 8/8 + …), which is infinite. But obviously you wouldn’t buy these tickets if they cost $50 each. This is because you’d probably run out of money before getting to the long run that the expected value measures.

    I’m thinking of a natural number. What distribution do you put on this natural number? In particular, what is its median, or even its mode?

    You’re playing a game where you have a 40% chance to win your bet and a 60% chance to lose, but you employ the Martingale strategy, where you double your bet each time? The only states where you stop betting are when you win 1, so your expected value is +1. However, after n bets, your expected value is 1-(6/5)^n, which diverges to negative infinity as n approaches infinity.

    You get to have a 1 in X chance for $X, but you get to pick any value for X in the range [1, inf). What value do you pick? Why specifically that value?

    Some guy runs up to you in the street, and he’s like “You should believe in my god Zulu, who will grant you his wealth if you believe in him.”
    You: “I think that’s very unlikely. I think that only has like a 1 in [X] chance of being true.”
    Guy: “Well, lucky for you, the amount of wealth that he’ll give you is $[X],000. So, your expected value for believing is $1,000.”

    By the way, the number I was thinking of earlier was 9.