Update and publish digit sum patterns article
This commit is contained in:
parent
ca1abf951f
commit
a573a0b765
|
@ -2,7 +2,7 @@
|
||||||
title: Digit Sum Patterns and Modular Arithmetic
|
title: Digit Sum Patterns and Modular Arithmetic
|
||||||
date: 2021-12-30T15:42:40-08:00
|
date: 2021-12-30T15:42:40-08:00
|
||||||
tags: ["Ruby", "Mathematics"]
|
tags: ["Ruby", "Mathematics"]
|
||||||
draft: true
|
description: "In this article, we explore the patterns created by remainders from division."
|
||||||
---
|
---
|
||||||
|
|
||||||
When I was in elementary school, our class was briefly visited by our school's headmaster.
|
When I was in elementary school, our class was briefly visited by our school's headmaster.
|
||||||
|
@ -79,39 +79,39 @@ divisor (what a mouthful). In mathematics, we typically use
|
||||||
\\(a|b\\) to say \\(a\\) divides \\(b\\), or, as we have seen above, that the remainder of dividing
|
\\(a|b\\) to say \\(a\\) divides \\(b\\), or, as we have seen above, that the remainder of dividing
|
||||||
\\(b\\) by \\(a\\) is zero.
|
\\(b\\) by \\(a\\) is zero.
|
||||||
|
|
||||||
Working with remainders actually comes up pretty commonly in discrete math. A well-known
|
Working with remainders actually comes up pretty frequently in discrete math. A well-known
|
||||||
example I'm aware of is the [RSA algorithm](https://en.wikipedia.org/wiki/RSA_(cryptosystem)),
|
example I'm aware of is the [RSA algorithm](https://en.wikipedia.org/wiki/RSA_(cryptosystem)),
|
||||||
which works with remainders resulting from dividing by a product of two large prime numbers.
|
which works with remainders resulting from dividing by a product of two large prime numbers.
|
||||||
But what's a good way to write, in numbers and symbols, the claim that "\\(a\\) divides \\(b\\)
|
But what's a good way to write, in numbers and symbols, the claim that "\\(a\\) divides \\(b\\)
|
||||||
with remainder \\(r\\)"? Well, we know that dividing yields a quotient (possibly zero) and a remainder
|
with remainder \\(r\\)"? Well, we know that dividing yields a quotient (possibly zero) and a remainder
|
||||||
(also possibly zero). Let's call the quotient \\(k\\).
|
(also possibly zero). Let's call the quotient \\(q\\).
|
||||||
{{< sidenote "right" "r-less-note" "Then, we know that when dividing \(b\) by \(a\) we have:" >}}
|
{{< sidenote "right" "r-less-note" "Then, we know that when dividing \(b\) by \(a\) we have:" >}}
|
||||||
It's important to point out that for the equation in question to represent division
|
It's important to point out that for the equation in question to represent division
|
||||||
with quotient \(k\) and remainder \(r\), it must be that \(r\) is less than \(a\).
|
with quotient \(q\) and remainder \(r\), it must be that \(r\) is less than \(a\).
|
||||||
Otherwise, you could write \(r = s + a\) for some \(s\), and end up with
|
Otherwise, you could write \(r = s + a\) for some \(s\), and end up with
|
||||||
{{< latex >}}
|
{{< latex >}}
|
||||||
\begin{aligned}
|
\begin{aligned}
|
||||||
& b = ka + r \\
|
& b = qa + r \\
|
||||||
\Rightarrow\ & b = ka + (s + a) \\
|
\Rightarrow\ & b = qa + (s + a) \\
|
||||||
\Rightarrow\ & b = (k+1)a + s
|
\Rightarrow\ & b = (q+1)a + s
|
||||||
\end{aligned}
|
\end{aligned}
|
||||||
{{< /latex >}}
|
{{< /latex >}}
|
||||||
|
|
||||||
In plain English, if \(r\) is bigger than \(a\) after you've divided, you haven't
|
In plain English, if \(r\) is bigger than \(a\) after you've divided, you haven't
|
||||||
taken out "as much \(a\) from your dividend as you could", and the actual quotient is
|
taken out "as much \(a\) from your dividend as you could", and the actual quotient is
|
||||||
larger than \(k\).
|
larger than \(q\).
|
||||||
{{< /sidenote >}}
|
{{< /sidenote >}}
|
||||||
|
|
||||||
{{< latex >}}
|
{{< latex >}}
|
||||||
\begin{aligned}
|
\begin{aligned}
|
||||||
& b = ka + r \\
|
& b = qa + r \\
|
||||||
\Rightarrow\ & b-r = ka \\
|
\Rightarrow\ & b-r = qa \\
|
||||||
\end{aligned}
|
\end{aligned}
|
||||||
{{< /latex >}}
|
{{< /latex >}}
|
||||||
|
|
||||||
We only really care about the remainder here, not the quotient, since it's the remainder
|
We only really care about the remainder here, not the quotient, since it's the remainder
|
||||||
that determines if something is divisible or not. From the form of the second equation, we can
|
that determines if something is divisible or not. From the form of the second equation, we can
|
||||||
deduce that \\(b-r\\) is divisible by \\(a\\) (it's literally equal to \\(a\\) times \\(k\\),
|
deduce that \\(b-r\\) is divisible by \\(a\\) (it's literally equal to \\(a\\) times \\(q\\),
|
||||||
so it must be divisible). Thus, we can write:
|
so it must be divisible). Thus, we can write:
|
||||||
|
|
||||||
{{< latex >}}
|
{{< latex >}}
|
||||||
|
@ -332,7 +332,7 @@ Let's explore this some more with a different divisor, say 12. We fill find that
|
||||||
of 3, 7 has a cycle length of 12, 9 has a cycle length of 4. What's
|
of 3, 7 has a cycle length of 12, 9 has a cycle length of 4. What's
|
||||||
happening here? To see, let's divide 12 __by these cycle lengths__. For 8, we get (12/3) = 4.
|
happening here? To see, let's divide 12 __by these cycle lengths__. For 8, we get (12/3) = 4.
|
||||||
For 7, this works out to 1. For 9, it works out to 3. These new numbers, 4, 1, and 3, are actually
|
For 7, this works out to 1. For 9, it works out to 3. These new numbers, 4, 1, and 3, are actually
|
||||||
the __greatest common factors__ of 8, 3, and 7 with 12, respectively. The greatest common factor
|
the __greatest common factors__ of 8, 7, and 3 with 12, respectively. The greatest common factor
|
||||||
of two numbers is the largest number that divides them both. We thus write down our guess
|
of two numbers is the largest number that divides them both. We thus write down our guess
|
||||||
for the length of a cycle:
|
for the length of a cycle:
|
||||||
|
|
||||||
|
@ -410,7 +410,18 @@ Lastly, recall that our patterns would spiral away from the center whenever a \\
|
||||||
\\(k\\) is, we can restate this as "\\(d/\\text{gcd}(d,n)\\) is divisible by 4". But if we pick
|
\\(k\\) is, we can restate this as "\\(d/\\text{gcd}(d,n)\\) is divisible by 4". But if we pick
|
||||||
\\(n=d-1\\), the greatest common factor has to be \\(1\\) (see [this section below](#divisors-of-n-and-n-1)), so we can even further simplify this "\\(d\\) is divisible by 4".
|
\\(n=d-1\\), the greatest common factor has to be \\(1\\) (see [this section below](#divisors-of-n-and-n-1)), so we can even further simplify this "\\(d\\) is divisible by 4".
|
||||||
Thus, we can state simply that any divisor divisible by 4 is off-limits, as it will induce loops.
|
Thus, we can state simply that any divisor divisible by 4 is off-limits, as it will induce loops.
|
||||||
For example, pick \\(d=4\\). Running our algorithm for \\(n=d-1=3\\), we indeed find an infinite
|
For example, pick \\(d=4\\). Running our algorithm
|
||||||
|
{{< sidenote "right" "constructive-note" "for \(n=d-1=3\)," >}}
|
||||||
|
Did you catch that? From our work above, we didn't just find a condition that would prevent spirals;
|
||||||
|
we also found the precise number that would result in a spiral if this condition were violated!
|
||||||
|
This is because our proof is <em>constructive</em>: instead of just claiming the existence
|
||||||
|
of a thing, it also shows how to get that thing. Our proof in the earlier section (which
|
||||||
|
claimed that the divisor 9 would never create spirals) went by contradiction, which was
|
||||||
|
<em>not</em> constructive. Repeating that proof for a general \(d\) wouldn't have told us
|
||||||
|
the specific numbers that would spiral.<br>
|
||||||
|
<br>
|
||||||
|
This is the reason that direct proofs tend to be preferred over proofs by contradiction.
|
||||||
|
{{< /sidenote >}} we indeed find an infinite
|
||||||
spiral:
|
spiral:
|
||||||
|
|
||||||
{{< figure src="pattern_3_4.svg" caption="Spiral generated by the number 3 with divisor 4." class="tiny" alt="Spiral generated by the number 3 by summing digits." >}}
|
{{< figure src="pattern_3_4.svg" caption="Spiral generated by the number 3 with divisor 4." class="tiny" alt="Spiral generated by the number 3 by summing digits." >}}
|
||||||
|
@ -420,7 +431,7 @@ Let's try again. Pick \\(d=8\\); then, for \\(n=d-1=7\\), we also get a spiral:
|
||||||
{{< figure src="pattern_7_8.svg" caption="Spiral generated by the number 7 with divisor 8." class="tiny" alt="Spiral generated by the number 7 by summing digits." >}}
|
{{< figure src="pattern_7_8.svg" caption="Spiral generated by the number 7 with divisor 8." class="tiny" alt="Spiral generated by the number 7 by summing digits." >}}
|
||||||
|
|
||||||
A poem comes to mind:
|
A poem comes to mind:
|
||||||
> Turning and turning in the wydening gyre
|
> Turning and turning in the widening gyre
|
||||||
>
|
>
|
||||||
> The falcon cannot hear the falconner;
|
> The falcon cannot hear the falconner;
|
||||||
|
|
||||||
|
@ -450,7 +461,7 @@ First, let's update our condition. Before, we had "\\(d\\) cannot be divisible b
|
||||||
we aren't constraining ourselves to only 4, but rather using a generic variable \\(c\\).
|
we aren't constraining ourselves to only 4, but rather using a generic variable \\(c\\).
|
||||||
We then end up with "\\(d\\) cannot be divisible by \\(c\\)". For instance, suppose we kept
|
We then end up with "\\(d\\) cannot be divisible by \\(c\\)". For instance, suppose we kept
|
||||||
our divisor as 9 for the time being, but started turning 3 times instead of 4. This
|
our divisor as 9 for the time being, but started turning 3 times instead of 4. This
|
||||||
violates are divisibility condtion, and we once again end up with a spiral:
|
violates our divisibility condtion, and we once again end up with a spiral:
|
||||||
|
|
||||||
{{< figure src="pattern_8_9_t3.svg" caption="Pattern generated by the number 8 in base 10 while turning 3 times." class="tiny" alt="Pattern generated by the number 3 by summing digits and turning 120 degrees." >}}
|
{{< figure src="pattern_8_9_t3.svg" caption="Pattern generated by the number 8 in base 10 while turning 3 times." class="tiny" alt="Pattern generated by the number 3 by summing digits and turning 120 degrees." >}}
|
||||||
|
|
||||||
|
@ -483,8 +494,8 @@ a triangle:
|
||||||
|
|
||||||
As long as you rotate by the same amount each time (and you will, since the cycle length determines
|
As long as you rotate by the same amount each time (and you will, since the cycle length determines
|
||||||
how many times you turn, and the cycle length never changes), you can do so for any number
|
how many times you turn, and the cycle length never changes), you can do so for any number
|
||||||
of directions. For instance, here's a similar visualization for a five-turn system, where
|
of directions. For instance, here's a similar visualization in which
|
||||||
each turn is 72 degrees:
|
there are 5 possible directions, and where each turn is consequently 72 degrees:
|
||||||
|
|
||||||
{{< figure src="turn_5_anim.gif" caption="Pentagon formed by five 72-degree turns." class="small" alt="Pentagon formed by five 72-degree turns." >}}
|
{{< figure src="turn_5_anim.gif" caption="Pentagon formed by five 72-degree turns." class="small" alt="Pentagon formed by five 72-degree turns." >}}
|
||||||
|
|
||||||
|
@ -537,14 +548,14 @@ after \\(360/\\text{gcd}(360, t)\\) turns, we'll end up facing the way that we s
|
||||||
|
|
||||||
So far, so good. What I don't like about this, though, is that we have all of these
|
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,
|
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,
|
something like 73 degrees (if there are five possible directions) 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
|
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,
|
using a handful! That's wasteful. Instead, observe that for \\(c\\) possible turns,
|
||||||
the smallest possible turn is \\(360/c\\). Let's call this turn \\(\\theta\\) (theta).
|
the smallest possible turn angle is \\(360/c\\). Let's call this angle \\(\\theta\\) (theta).
|
||||||
Now, notice that we always turn in multiples of \\(\\theta\\): a single turn moves us \\(\\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
|
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
|
the number of turns that we find ourselves rotated by after a single cycle,
|
||||||
equation can be written as to:
|
we have \\(t=r\\theta\\), and our turning equation can be written as:
|
||||||
|
|
||||||
{{< latex >}}
|
{{< latex >}}
|
||||||
kr\theta \equiv 0\ (\text{mod}\ c\theta)
|
kr\theta \equiv 0\ (\text{mod}\ c\theta)
|
||||||
|
@ -567,7 +578,7 @@ And finally, observing that \\(kr=kr-0\\), we have:
|
||||||
|
|
||||||
This equivalence says the same thing as our earlier one; however, instead of being in terms
|
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\\).
|
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
|
Now, recall once again that the smallest number of steps \\(k>0\\) for which this equivalence holds is
|
||||||
\\(k = c/\\text{gcd}(c,r)\\).
|
\\(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.
|
We're close now: we have a sequence of \\(k\\) steps that will lead us back to the beginning.
|
||||||
|
@ -623,6 +634,18 @@ is one more than the _divisor_ (we started with numbers in the usual base 10, bu
|
||||||
|
|
||||||
{{< 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." >}}
|
{{< 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." >}}
|
||||||
|
|
||||||
|
### Conclusion
|
||||||
|
Today we peeked under the hood of a neat mathematical trick that was shown to me by my headmaster
|
||||||
|
over 10 years ago now. Studying what it was that made this trick work led us to play with
|
||||||
|
the underlying mathematics some more, and extend the trick to more situations (and prettier
|
||||||
|
patterns). I hope you found this as interesting as I did!
|
||||||
|
|
||||||
|
By the way, the kind of math that we did in this article is most closely categorized as
|
||||||
|
_number theory_. Check it out if you're interested!
|
||||||
|
|
||||||
|
All that remains are some proofs I omitted from the original article since they were taking
|
||||||
|
up a lot of space (and were interrupting the flow of the explanation). They are listed below.
|
||||||
|
|
||||||
### Referenced Proofs
|
### Referenced Proofs
|
||||||
|
|
||||||
#### Adding Two Congruences
|
#### Adding Two Congruences
|
||||||
|
@ -676,7 +699,7 @@ if \\(a=fc\\) and \\(b=fd\\), then \\(c\\) and \\(d\\) have no common factors ot
|
||||||
\\(\\text{gcd}(c,d)=1\\)).
|
\\(\\text{gcd}(c,d)=1\\)).
|
||||||
|
|
||||||
__Proof__: Suppose that \\(c\\) and \\(d\\) do have sommon factor, \\(e\\neq1\\). In that case, we have
|
__Proof__: Suppose that \\(c\\) and \\(d\\) do have sommon factor, \\(e\\neq1\\). In that case, we have
|
||||||
\\(c=ei\\) and \\(d=ej\\) for some \\(i\\) and \\(j\\). then, we have \\(a=fei\\), and \\(b=fej\\).
|
\\(c=ei\\) and \\(d=ej\\) for some \\(i\\) and \\(j\\). Then, we have \\(a=fei\\), and \\(b=fej\\).
|
||||||
From this, it's clear that both \\(a\\) and \\(b\\) are divisible by \\(fe\\). Since \\(e\\)
|
From this, it's clear that both \\(a\\) and \\(b\\) are divisible by \\(fe\\). Since \\(e\\)
|
||||||
is greater than \\(1\\), \\(fe\\) is greater than \\(f\\). But our assumptions state that
|
is greater than \\(1\\), \\(fe\\) is greater than \\(f\\). But our assumptions state that
|
||||||
\\(f\\) is the greatest common divisor of \\(a\\) and \\(b\\)! We have arrived at a contradiction.
|
\\(f\\) is the greatest common divisor of \\(a\\) and \\(b\\)! We have arrived at a contradiction.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user