diff --git a/content/blog/modulo_patterns/index.md b/content/blog/modulo_patterns/index.md index 2a02424..4cd9d31 100644 --- a/content/blog/modulo_patterns/index.md +++ b/content/blog/modulo_patterns/index.md @@ -462,9 +462,9 @@ Here's one such pattern: Hold on a moment; it's actully not so obvious why our condition _still_ works. When we just turned on a grid, things were simple. As long as we didn't end up facing the same way we started, we will eventually perform the exact same motions in reverse. The same is not true when turning 120 degrees, like -we suggested. Here's a circle with the turn angles labeled: +we suggested. Here's an animated circle all of the turns we would make: -{{< figure src="turn_3_1.png" caption="Orientations when turning 120 degrees" class="small" alt="Possible orientations when turning 120 degrees." >}} +{{< figure src="turn_3_1.gif" caption="Orientations when turning 120 degrees" class="small" alt="Possible orientations when turning 120 degrees." >}} We never quite do the exact _opposite_ of any one of our movements. So then, will we come back to the origin anyway? Well, let's start simple. Suppose we always turn by exactly one 120-degree increment @@ -498,21 +498,132 @@ instead of 1? Even though we first turn a whole 240 degrees, the second time we turn we "overshoot" our initial bearing, and end up at 120 degrees compared to it. As soon as we turn 240 more degrees (turning the third time), we end up back at 0. -In short, even though we "visited" each bearing in a different order, we visited them all. +In short, even though we "visited" each bearing in a different order, we visited them all, and +exactly once at that. Here's a visualization: -{{< figure src="turn_3_2.png" caption="Orientations when turning 120 degrees, twice at a time" class="small" alt="Possible orientations when turning 120 degrees, twice at a time." >}} +{{< figure src="turn_3_2.gif" caption="Orientations when turning 120 degrees, twice at a time" class="small" alt="Possible orientations when turning 120 degrees, twice at a time." >}} -Let's try put some mathematical backing to this "visited them all" idea. +Note that even though in the above picture it looks like we're just turning left instead of right, +that's not the case; a single turn of 240 degrees is more than half the circle, so our second +bearing ends up on the left side of the circle even though we turn right. -{{< todo >}}Remainders, visited them all, etc.{{< /todo >}} +Just to make sure we really see what's happening, let's try this when there are 5 possible directions, +and when we still make two turns (now of 72 degrees each) -But let's not be so boring. We can branch out some, of course. +{{< figure src="turn_5_2.gif" caption="Orientations when turning 72 degrees, twice at a time" class="small" alt="Possible orientations when turning 72 degrees, twice at a time." >}} + +Let's try put some mathematical backing to this "visited them all" idea, and turning in general. +First, observe that as soon as we turn 360 degrees, it's as good as not turning at all - we end +up facing up again. If we turned 480 degrees (that is, two turns of 240 degrees each), the first +360 can be safely ignored, since it puts us where we started; only the 120 degrees that remain +are needed to figure out our final bearing. In short, the final direction we're facing is +the remainder from dividing by 360. We already know how to formulate this using modular arithmetic: +if we turn \\(t\\) degrees \\(k\\) times, and end up at final bearing (remainder) \\(b\\), this +is captured by: + +{{< latex >}} + kt \equiv b\ (\text{mod}\ 360) +{{< /latex >}} + +Of course, if we end up facing the same way we started, we get the familiar equivalence: + +{{< latex >}} + kt \equiv 0\ (\text{mod}\ 360) +{{< /latex >}} + +Even though the variables in this equivalence mean different things now than they did last +time we saw it, the mathematical properties remain the same. For instance, we can say that +after \\(360/\\text{gcd}(360, t)\\) turns, we'll end up facing the way that we started. + +So far, so good. What I don't like about this, though, is that we have all of these +numbers of degrees all over our equations: 72 degrees, 144 degrees, and so forth. However, +something like 73 degrees (in a 5-turn system) is just not a valid bearing, +and nor is 71. We have so many possible degrees (360 of them, to be exact), but we're only +using a handful! That's wasteful. Instead, observe that for a system with \\(c\\) turns, +the smallest possible turn is \\(360/c\\). Let's call this turn \\(\\theta\\) (theta). +Now, notice that we always turn in multiples of \\(\\theta\\): a single turn moves us \\(\\theta\\) +degrees, two turns move us \\(2\\theta\\) degrees, and so on. If we define \\(r\\) to be +the number of turns after a single cycle, we have \\(t=r\\theta\\), and our turning +equation can be written as to: + +{{< latex >}} + kr\theta \equiv 0\ (\text{mod}\ c\theta) +{{< /latex >}} + +Now, once again, recall that the above equivalence is just notation for the following: + +{{< latex >}} + \begin{aligned} + & c\theta|kr\theta \\ + \Leftrightarrow\ & c|kr + \end{aligned} +{{< /latex >}} + +And finally, observing that \\(kr=kr-0\\), we have: + +{{< latex >}} + kr \equiv 0\ (\text{mod}\ c) +{{< /latex >}} + +This equivalence says the same thing as our earlier one; however, instead of being in terms +of degrees, it's in terms of the number of turns \\(c\\) and the turns-per-cycle \\(r\\). +Now, recall once again that for this equivalence to hold in \\(k>0\\) steps, we need +\\(k = c/\\text{gcd}(c,r)\\). + +We're close now: we have a sequence of \\(k\\) steps that will lead us back to the beginning. +What's left is to show that these \\(k\\) steps are evenly distributed throughout our circle, +which is the key property that makes it possible for us to make a polygon out of them (and +thus end up back where we started). + +To show this, say that we have a largest common divisor \\(f=\\text{gcd}(c,r)\\), and that \\(c=fe\\) and \\(r=fs\\). We can once again "divide through" by \\(f\\), and +get: + +{{< latex >}} + ks \equiv 0\ (\text{mod}\ e) +{{< /latex >}} + +Now, we know that \\(\\text{gcd}(e,s)=1\\) ([see this section below](#numbers-divided-by-their-textgcd-have-no-common-factors)), and thus: + +{{< latex >}} +k = e/\text{gcd}(e,s) = e +{{< /latex >}} + +That is, our cycle will repeat after \\(e\\) remainders. But wait, we've only got \\(e\\) possible +remainders: the numbers \\(0\\) through \\(e-1\\)! Thus, for a cycle to repeat after \\(e\\) remainders, +all possible remainders must occur. For a concrete example, take \\(e=5\\); our remainders will +be the set \\(\\{0,1,2,3,4\\}\\). Now, let's "multiply back through" +by \\(f\\): + +{{< latex >}} + kfs \equiv 0\ (\text{mod}\ fe) +{{< /latex >}} + +We still have \\(e\\) possible remainders, but this time they are multiplied by \\(f\\). +For example, taking \\(e\\) to once again be equal to \\(5\\), we have the set of possible remainders +\\(\\{0, f, 2f, 3f, 4f\\}\\). The important bit is that these remainders are all evenly spaced, and +that space between them is \\(f=\\text{gcd}(c,r)\\). + +Let's recap: we have confirmed that for \\(c\\) possible turns (4 in our original formulation), +and \\(r\\) turns at a time, we will always loop after \\(k=c/\\text{gcd}(c,r)\\) steps, +evenly spaced out at \\(\\text{gcd}(c,r)\\) turns. No specific properties from \\(c\\) or \\(r\\) +are needed for this to work. Finally, recall from the previous +section that \\(r\\) is zero (and thus, our pattern breaks down) whenever the divisor \\(d\\) (9 in our original formulation) is itself +divisible by \\(c\\). And so, __as long as we pick a system with \\(c\\) possible directions +and divisor \\(d\\), we will always loop back and create a pattern as long as \\(c\\nmid d\\) (\\(c\\) +does not divide \\(d\\))__. + +Let's try it out! There's a few pictures below. When reading the captions, keep in mind that the _base_ +is one more than the _divisor_ (we started with numbers in the usual base 10, but divided by 9). {{< figure src="pattern_1_7_t5.svg" caption="Pattern generated by the number 1 in base 8 while turning 5 times." class="tiny" alt="Pattern generated by the number 1 by summing digits in base 8 and turning 72 degrees." >}} +{{< figure src="pattern_3_4_t7.svg" caption="Pattern generated by the number 3 in base 5 while turning 7 times." class="tiny" alt="Pattern generated by the number 3 by summing digits in base 5 and turning 51 degrees." >}} + {{< figure src="pattern_3_11_t6.svg" caption="Pattern generated by the number 3 in base 12 while turning 6 times." class="tiny" alt="Pattern generated by the number 3 by summing digits in base 12 and turning 60 degrees." >}} -### Omitted Proofs +{{< figure src="pattern_2_11_t7.svg" caption="Pattern generated by the number 2 in base 12 while turning 7 times." class="tiny" alt="Pattern generated by the number 2 by summing digits in base 12 and turning 51 degrees." >}} + +### Referenced Proofs #### Adding Two Congruences __Claim__: If for some numbers \\(a\\), \\(b\\), \\(c\\), \\(d\\), and \\(k\\), we have diff --git a/content/blog/modulo_patterns/pattern_2_11_t7.svg b/content/blog/modulo_patterns/pattern_2_11_t7.svg new file mode 100644 index 0000000..f11b429 --- /dev/null +++ b/content/blog/modulo_patterns/pattern_2_11_t7.svg @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/content/blog/modulo_patterns/pattern_3_4_t7.svg b/content/blog/modulo_patterns/pattern_3_4_t7.svg new file mode 100644 index 0000000..ca176c3 --- /dev/null +++ b/content/blog/modulo_patterns/pattern_3_4_t7.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/content/blog/modulo_patterns/turn_3_1.gif b/content/blog/modulo_patterns/turn_3_1.gif new file mode 100644 index 0000000..303ab9a Binary files /dev/null and b/content/blog/modulo_patterns/turn_3_1.gif differ diff --git a/content/blog/modulo_patterns/turn_3_1.png b/content/blog/modulo_patterns/turn_3_1.png deleted file mode 100644 index af17a27..0000000 Binary files a/content/blog/modulo_patterns/turn_3_1.png and /dev/null differ diff --git a/content/blog/modulo_patterns/turn_3_2.gif b/content/blog/modulo_patterns/turn_3_2.gif new file mode 100644 index 0000000..cab38e3 Binary files /dev/null and b/content/blog/modulo_patterns/turn_3_2.gif differ diff --git a/content/blog/modulo_patterns/turn_3_2.png b/content/blog/modulo_patterns/turn_3_2.png deleted file mode 100644 index a00b66c..0000000 Binary files a/content/blog/modulo_patterns/turn_3_2.png and /dev/null differ diff --git a/content/blog/modulo_patterns/turn_3_anim.gif b/content/blog/modulo_patterns/turn_3_anim.gif index 0033337..651c649 100644 Binary files a/content/blog/modulo_patterns/turn_3_anim.gif and b/content/blog/modulo_patterns/turn_3_anim.gif differ diff --git a/content/blog/modulo_patterns/turn_5_1.png b/content/blog/modulo_patterns/turn_5_1.png deleted file mode 100644 index 1784ea2..0000000 Binary files a/content/blog/modulo_patterns/turn_5_1.png and /dev/null differ diff --git a/content/blog/modulo_patterns/turn_5_2.gif b/content/blog/modulo_patterns/turn_5_2.gif new file mode 100644 index 0000000..0853099 Binary files /dev/null and b/content/blog/modulo_patterns/turn_5_2.gif differ diff --git a/content/blog/modulo_patterns/turn_5_anim.gif b/content/blog/modulo_patterns/turn_5_anim.gif index 9f60d8b..5de28ce 100644 Binary files a/content/blog/modulo_patterns/turn_5_anim.gif and b/content/blog/modulo_patterns/turn_5_anim.gif differ