Tuesday, 29 June 2021

Equal Temperament Tuning

Part 1 of Mathematics and Music

On February 2nd 2018, I made a short post titled The Mathematics of Music and this current post builds on the content that I first introduced there.

The idea of doing a series of posts on Mathematics and Music occurred to me recently and one of the first and most basic topic in this regard were the ratios involved in the Western musical scales. I found a very good resource for this topic titled Why 12 notes to the Octave and the author begins with this statement:

The Greeks realised that sounds which have frequencies in rational proportion are perceived as harmonious. For example, a doubling of frequency gives an octave. A tripling of frequency gives a perfect fifth one octave higher. They didn't know this in terms of frequencies, but in terms of lengths of vibrating strings. Pythagoras, who experimented with a monochord, noticed that subdividing a vibrating string into rational proportions produces consonant sounds. This translates into frequencies when you know that the fundamental frequency of the string is inversely proportional to its length, and that its other frequencies are just whole number multiples of the fundamental. 

The key point is that "sounds which have frequencies in rational proportion are perceived as harmonious" and the most important of these ratios is 3:2. The author continues:

The chromatic scale reflects this fact. In the 18th and 19th centuries, the chromatic scale was tuned using the idea of 3/2. In the most elegant of these, Thomas Young's tuning, several of the fifths were set exactly to 3/2, and the others were tempered slightly (to make octaves exact).

In the modern equal temperament (which came into practical use during the early part of the 20th century), all fifths are tuned to 2^(7/12)=1.49651..., slightly less than 3/2, and 12 repetitions of this ratio gets us back to where we started (after dropping down 7 octaves).

Of the various intervals, the only ones that are really well captured by tempered versions of the 3/2 scheme are: unison, 5th, major 2nd, and their reciprocals (octave, 4th, minor 7th).

The author then asks two key questions: 

  • Why 3/2? The choice of 3/2 says that, next to the octave, it should be regarded as the most important interval. 

  • Why do 12 steps work nicely? Interestingly, this can be explained in terms of simple number theory, namely continued fractions.
Ah, continued fractions! This is where the Mathematics comes in. The author remarks that it is necessary to understand when a power of 3/2 will be close to a power of 2 (because 2 represents an octave and we want a power of 2 that will be close to a power of 3/2). So we set an equation:$$\begin{align} \left ( \frac{3}{2}\right )^a &=2^b \text{ where }a \text{ and }b \text{ are natural numbers}\\\frac{3}{2} &=2^{\frac{b}{a}}\\&=2^x \text{ where }x \text{ is a real number}\\
x&=\frac{\log \left ( \frac{3}{2} \right )}{\log(2)}\\

&\approx 0.584962500721 \dots \end{align}$$There are no rational values of \(a\) and \(b\) that satisfy the equation which is why it is necessary to approximate with a real number \(x\). The continued fraction approximations to \(x\) are shown in the SageMath code in Figure 1 with permalink included:


Figure 1: permalink

We see that 7/12 gives a reasonable approximation (0.5833333... versus 0.5849625...). If we start with the octave between note A3 (220 Hz) and A4 (440 Hz) and divide it into 12 semitones according to \(220 \times 2^{k/12}\) where \(k=0 \dots 12\), we get what's shown in Figure 2.


Figure 2: link

Figure 3 shows what two different representations of the octaves:

Figure 3: link

As the author of Why 12 notes to the Octave remarks, there are other possible divisions and one of them is into 19 parts because 11/19 = 0.578947... is pretty close to 0.5849625... and this produces the situation shown in Figure 4 where octave is divided into 19 "semitones" according to  \(220 \times 2^{k/19}\) where \(k=0 \dots 19\).


Figure 4:  link

Let's remember that the above scales, and in fact nearly all modern scales, use equal temperament. As Wikipedia explains:
There are two main families of tuning systems: equal temperament and just tuning. Equal temperament scales are built by dividing an octave into intervals which are equal on a logarithmic scale, which results in perfectly evenly divided scales, but with ratios of frequencies which are irrational numbers. Just scales are built by multiplying frequencies by rational numbers, which results in simple ratios between frequencies, but with scale divisions that are uneven.

This is a big topic and I've only scratched the surface of it. More later. 

SOD ET AL

SOD stands in a mathematical context for Sum of Digits and it can also be written as SoD or sod. Unlike a number's primeness or non-primeness, a number's SoD is peculiar to the number system being used and is thus of interest mainly in recreational mathematics. My diurnal age today is 26384 with a sum of digits of 23. When these two numbers are added together, the result is a prime number, 26407. This qualifies 26384 for inclusion in OEIS A047791:


 A047791

Numbers \(n\) such that \(n\) plus digit sum of \(n\) (A007953) equals a prime.       


There are 2919 such numbers in the range of numbers from 1 to 26384, constituting about 11.1% of the total number. In the same range, there are 2897 primes and so the totals are nearly identical. This is not surprising because the operation of adding the sum of digits of a number to itself simply changes the number into another number of slightly higher value, without regard to its being prime or composite.


ODDS AND EVENS


Recently, I made a series of posts that involved adding the odd digits to a number and subtracting the even digits. These posts were titled:
I covered a lot of material in those posts so refer to those for more details.


SELF AND JUNCTION NUMBERS

In this post, I want to collect together some of the other mathematical activities that involve the sum of the digits of a number or the manipulation of the digits is some way. Let's start with the concept of a self number. If there does NOT exist a number \(x\) such that \(x\) + sod(\(x\)) = \(n\) for some number \(n\), then \(n\) is said to be a self number. There are 10 self numbers in the range from 26300 to 26400:

26307, 26318, 26320, 26331, 26342, 26353, 26364, 26375, 26386, 26397

Looking at the above numbers, it can be seen that 26308 is not in the list. This is because:

26285 + sod(26285) = 26285 + 23 = 26308

Apart from self numbers, most numbers are like 26385. There is only one value of \(x\) for which \(x\) + sod(\(x\)) = \(n\). If there is more than one value of x then the number is said to be a junction number. In the range from 26300 to 26400, there are nine junction numbers:

26311 is a junction number [26291, 26300]
26313 is a junction number [26292, 26301]
26315 is a junction number [26293, 26302]
26317 is a junction number [26294, 26303]
26319 is a junction number [26295, 26304]
26321 is a junction number [26296, 26305]
26323 is a junction number [26297, 26306]
26325 is a junction number [26298, 26307]
26327 is a junction number [26299, 26308]

Thus we see, using the first number 26311 as an example, that: 
  • 26291 + sod(26291) = 26291 + 20 = 26311 and 
  • 26300 + sod(26300) = 26300 + 11 = 26311
I've written about self and junction numbers in an eponymous post from October 25th 2018. The numbers above give an idea of the relative proportions of such numbers: about 10% are self numbers, 10% are junction numbers and 80% are neither.


HAPPY NUMBERS

Happy numbers don't involve the sum of the digits per se but instead are concerned with the sum of the digits squared. If this process is applied recursively and the end result is 1, then the number is said to be happy. For example, 94 is an example of such a number because:

 94 → 97 → 130 → 10 → 1 

Only about 15% of numbers are happy. The rest end up in a loop (4, 16, 37, 58, 89, 145, 42, 20, 4) and 61 is an example of such a number because:

61 → 37 → 58 → 89 and the loop has been entered

I've written about happy numbers in a series of posts:

SELFIE NUMBERS

I wrote about these sorts of numbers in an eponymous post on March 27th 2020. In it, I quoted the following:
Numbers represented by their own digits by certain operations are considered as selfie numbers. Some times they are called wild narcissistic numbers. There are many ways of representing selfie numbers. They can be represented in digit’s order, reverse order of digits, increasing and/or decreasing order of digits, etc. These can be obtained by use of basis operations along with factorial, squareroot, Fibonacci sequence, Triangular numbers, binomial coefficients, s-gonal values, centered polygonal numbers, etc. In this work, we have written selfie numbers by use of concatenation, along with factorial and square-root. The concatenation idea is used in a very simple way. The work is limited up to 5 digits. Work on higher digits shall be dealt elsewhere. Source.

I use the example of 25926 that can be expressed as: 

((−2+5)!)!×C(9,2)+6 = (3!)! x 36 + 6 = 6! x 36 + 6 = 720 x 36 + 6 = 25926

Another example is \(39304:=((4||03)−9)^3\) where || stands for concatenation.

This is a big topic and it has been covered in detail in my prementioned blog post.


FRIEDMAN NUMBERS

These could be considered a subset of the selfie numbers but they form a category in their own right and are constructed much more simply. I wrote about these in a blog post from October 8th 2020 titled Forming Equations from Integers. To quote:

Consider \(28547=(8+5)^4−(7×2)\) expressed in base 10, both sides use the same digits. An integer is a Friedman number if it can be put into an equation such that both sides use the same digits but the right hand side has one or more basic arithmetic operators (addition, subtraction, multiplication, division, exponentiation) interspersed. Brackets, as usual, are essential to clarify the order of operations. These numbers are named after Erich Friedman, Assoc. Professor of Mathematics at Stetson University. With the help of his students he has researched Friedman numbers in bases 2 through 10 and even with Roman numerals. When both sides use the digits in the same order, the number is called a ”nice” or ”strong” Friedman number. For example, \(3125=(3+[1×2])^5\).


NARCISSISTIC NUMBERS 

Selfie numbers are sometimes called wild narcissistic numbers but the proper narcissistic numbers. Numbers Aplenty defines them thus:

A number \(n\)  of \(k\)  digits is called narcissistic if it is equal to the sum of the \(k^{th}\) powers of its digits. For example, \(153\)  is narcissistic because \(153 = 1^3+5^3+3^3\). Narcissistic numbers are also called Armstrong or plus-perfect numbers. It has verified that there in fact only 88 such numbers. Those up to one million are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084, 548834, 1741725, 4210818, 9800817, 9926315.


D-POWERFUL NUMBERS 

D-powerful numbers are akin to narcissistic numbers but with more flexibility regarding the powers to which the digits may be raised. To quote from Numbers Aplenty:

An integer \(n\) is called digitally powerful (here d-powerful) if it can be expressed as a sum of positive powers of its digits. For example:$$3459872 = 3^1 + 4^6 + 5^5 + 9^6 + 8^3 + 7^7 + 2^{21}$$The first d-powerful numbers are:

1, 2, 3, 4, 5, 6, 7, 8, 9, 24, 43, 63, 89, 132, 135, 153, 175, 209, 224, 226, 262, 264, 267, 283, 332, 333, 334, 357, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 407, 445, 463, 518, 598, 629, 739, 794, 849, 935, 994


HARSHAD AND MORAN NUMBERS 

I've written about Harshad Numbers in the following posts:

In the first of the two posts, I posted from Wikipedia:
In recreational mathematics, a Harshad number (or Niven number) in a given number base, is an integer that is divisible by the sum of its digits when written in that base. Harshad numbers in base n are also known as n-harshad (or n-Niven) numbers. Harshad numbers were defined by D. R. Kaprekar, a mathematician from India. The word "harshad" comes from the Sanskrit harį¹£a (joy) + da (give), meaning joy-giver. The term “Niven number” arose from a paper delivered by Ivan M. Niven at a conference on number theory in 1977. 

They are quite frequent and account for about 12% of all the numbers up to 100,000. Here are the first few:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90, 100, 102, 108, 110, 111, 112, 114, 117, 120, 126, 132, 133, 135, 140, 144, 150, 152, 153, 156, 162, 171, 180, 190, 192, 195, 198, 200, 201, 204

If the dividend happens to be a prime number then the number is said to be a Moran number. To quote from Numbers Aplenty again:

A number \(n\) is a Moran number if \(n\) divided by the sum of its digits gives a prime number. For example, 111 is a Moran number because 111/(1+1+1) = 37 and 37 is a prime number. Moran numbers are a subset of Harshad numbers. 

The first few Moran numbers are: 

18, 21, 27, 42, 45, 63, 84, 111, 114, 117, 133, 152, 153, 156, 171, 190, 195, 198, 201, 207, 209, 222, 228. 


MAGNANIMOUS NUMBERS

I've written about these in an eponymous post December 27th 2020. To quote from Numbers Aplenty, a magnanimous number can be define as:

A number (which we assume of at least 2 digits) such that the sum obtained inserting a "+" among its digit in any position gives a prime.

For example, 4001 is magnanimous because the numbers 4+001=5, 40+01=41 and 400+1=401 are all prime numbers.

Since all the prime numbers are odd, except for 2, all the magnanimous numbers, except for 11, are either a sequence of odd digits followed by an even digit, or a sequence of even digits followed by an odd digits.

It is conjectured that the magnanimous numbers are finite and that probably the largest one is 97393713331910, while the largest one which is also a prime number itself is probably 608844043.

The first such numbers are:

11, 12, 14, 16, 20, 21, 23, 25, 29, 30, 32, 34, 38, 41, 43, 47, 49, 50, 52, 56, 58, 61, 65, 67, 70, 74, 76, 83, 85, 89, 92, 94, 98, 101, 110, 112, 116, 118, 130, 136, 152, 158, 170, 172, 203 


DIGITAL ROOT 

While I've not made a specific post about digital roots, I've nonetheless mentioned them in the following posts:

To quote from Wikipedia:
The digital root (also repeated digital sum) of a natural number in a given radix is the (single digit) value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-digit number is reached. In base 10, this is equivalent to taking the remainder upon division by 9 (except when the digital root is 9, where the remainder upon division by 9 will be 0).

Associated with the digital root is the concept of additive persistence defined as:

The additive persistence counts how many times we must sum its digits to arrive at its digital root. For example, the additive persistence of 2718 in base 10 is 2: first we find that 2 + 7 + 1 + 8 = 18, then that 1 + 8 = 9. 


SMITH AND HOAX NUMBERS 

I mentioned Smith numbers in a blog post dating back to April 21st 2016 and titled Repunits and Smith Numbers

Smith numbers are composite numbers with the property that the sum of their digits equals the sum of digits of their prime factors e.g. 22 → 2 + 2 = 4 and 22 = 2 * 11 → 2 + 1 + 1 = 4.

Hoax numbers are similar except they only consider distinct prime factors. Thus, for example, the Smith numbers 4 and 27 are excluded because the sums of their distinct prime factors are 2 and 3 respectively whereas their sums of digits are 4 and 9. The set of hoax numbers is a subset of the set of Smith numbers. 

666 is a Smith number since 666 = 2 * 3 * 3 * 37 and 6 + 6 + 6 = 2 + 3 + 3 + 3 + 7. 

The initial Smith numbers are:

 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438 

The initial hoax numbers are:

22, 58, 84, 85, 94, 136, 160, 166, 202, 234, 250, 265, 274, 308, 319, 336, 346, 355  
 

THE RATS SEQUENCE

I wrote about this in an eponymous post from September 26th 2020. Here is an excerpt:

A sequence produced by the instructions "reverse, add to the original, then sort the digits." For example, after 668, the next iteration is given by

668+866=1534

so the next term is 1345.

Applied to 1, the sequence gives: 

1, 2, 4, 8, 16, 77, 145, 668, 1345, 6677, 13444, 55778, 133345, 666677, 1333444, 5567777, 12333445, 66666677, 133333444, 556667777, 1233334444, 5566667777, 12333334444, 55666667777, 123333334444, 556666667777, 1233333334444, ... (OEIS A004000).

Conway conjectured that an initial number leads to a divergent period-two pattern (such as the above in which the numbers of threes and sixes in the middles of alternate terms steadily increase) or to a cycle (Guy 2004, p. 404).

The lengths of the cycles obtained by starting with n= 1, 2, ... are 0, 0, 8, 0, 0, 8, 0, 0, 2, 0, ... (OEIS A114611), where a 0 indicates that the sequence diverges.

Friday, 25 June 2021

Dying Rabbits

The title of this post may seem unusual for a mathematical blog but rabbits of course have a close association with the Fibonacci sequence. Well live, reproducing rabbits at least. The following explains what the rabbits are all about (source):

Fibonacci's Rabbits

In the West, the Fibonacci sequence first appears in the book Liber Abaci (1202) by Leonardo of Pisa, known as Fibonacci. Fibonacci considers the growth of an idealized (biologically unrealistic) rabbit population, assuming that:
    1. a single newly born pair of rabbits (one male, one female) are put in a field;
    2. rabbits are able to mate at the age of one month so that at the end of its second month a female can produce another pair of rabbits;
    3. rabbits never die and a mating pair always produces one new pair (one male, one female) every month from the second month on.
The puzzle that Fibonacci posed was: how many pairs will there be in one year?


Suppose we let the number of rabbit pairs in the field at the end of the nth month be denoted by \(F_n\).

Consider just the new "baby rabbit pairs" in the nth month. They must be equal in number to the pairs of rabbits that are mature enough to give birth to baby rabbits. This, of course, is precisely the number of rabbit pairs alive two months previously, \(F_{n−2}\).

Now the total number of rabbit pairs in the nth month is the number of pairs alive in the previous month (i.e., \(F_{n−1}\)) plus the number of new baby rabbit pairs, \(F_{n−2}\).

Thus, we have the following recursive definition for the nth Fibonacci number: $$F_0=F_1=1 \text{ and } F_n=F_{n−1}+F_{n−2}$$

The assumption that "rabbits never die" is big presumption for they do die and the formula for the Fibonacci sequence can be modified to account for this. I discovered this because my diurnal age at the time of writing this post is 26381 and this number happens to be a member of OEIS A023440:


 A023440

Dying rabbits: a(n) = a(n-1) + a(n-2) - a(n-10)                      


The sequence members, up to 26381, are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 88, 142, 228, 367, 590, 949, 1526, 2454, 3946, 6345, 10203, 16406, 26381.

The sequence is identical to the Fibonacci up to to the 10th term (55): 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 88, … because a(10) = a(9) + a(8) - a(0) = 34 + 21 - 0 = 55. However, with a(11) = a(10) + a(9) - a(1) = 55 + 34 - 1, it begins to differ because the oldest generation of rabbits dies off.

It’s easier to generate the terms using the generating function rather than a recursive sequence. In the case of OEIS A023440, this generating function is:$$\frac{x}{(x - 1)(x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 - 1)}$$Here is the SageMath code to generate the terms together with a permalink :

L, k=[], var('k')
S=sum(x^k for k in [2..9])
P=x/((x - 1)*(S - 1))
T=taylor(P,x,0,23).coefficients()
for t in T:
    L.append(t[0])
print(L)

It is easy to generalise this function to accommodate longevities other than 10. For example, changing the 9 to an 8 in the code above will generate OEIS A023439:

 
 A023439

Dying rabbits: a(n) = a(n-1) + a(n-2) - a(n-9)                        


Here is the SageMath code together with a permalink:

L, k=[], var('k')
S=sum(x^k for k in [2..8])
P=x/((x - 1)*(S - 1))
T=taylor(P,x,0,23).coefficients()
for t in T:
    L.append(t[0])
print(L)

There are OEIS sequences corresponding to a(n-3) to a(n-12). Of course the ratio of successive terms doesn't approach the golden ratio as it does with the Fibonacci terms. In the case of OEIS A023440, the ratio approaches 1.6079827279... rather than 1.6180339887... and in the case of OEIS A023439, the ratio approaches 1.6013473338...

So that's the story of the dying rabbits.

Wednesday, 23 June 2021

PolyKnights

 


To quote from Wikipedia:

A polyknight is a plane geometric figure formed by selecting cells in a square lattice that could represent the path of a chess knight in which doubling back is allowed. It is a polyform with square cells which are not necessarily connected, comparable to the polyking. Alternatively, it can be interpreted as a connected subset of the vertices of a knight's graph, a graph formed by connecting pairs of lattice squares that are a knight's move apart.

It would seem that the definition should read "doubling back is not allowed" since none of the examples shown features "doubling back" in the sense of returning to a previously occupied square.

Today I turned 26379 days and this number happens to be a member of OEIS A030446:


 A030446

Number of \(n\)-celled polyknights (polyominoes connected by knight's moves).   

In the comments to this sequence, it is stated that:

A polyknight is a variant of a polyomino in which two tiles a knight's move apart are considered adjacent. A polyknight need not be connected in the sense of a polyomino. These are free polyknights.

By free here is meant that the pieces can be picked up and turned over, as opposed to one-sided pieces that cannot be picked up and flipped over or fixed pieces that cannot be moved at all. Figures 1 and 2 help explain the differences, using tri-knights are examples:

Figure 1

Figure 2

The six possible tri-knights are shown in Figure 3:

Figure 3

Figure 4 shows a table from Wikipedia listing the different numbers of free, one-sided and fixed polyknights:

Figure 4

As can be seen, the sequence for \(n\) polyknights runs: 1, 1, 6, 35, 290, 2680, 26379 and the numbers very large very quickly. However, for one-sided and fixed polyknights, they rise ever more quickly. The shapes when \(n=7\) could be called heptaknights. Figure 5 shows three examples out of the 26379 possibilities for free heptaknights.

Figure 5

It's also apparent from the sequence terms in Figure 4 that I won't encounter any more polyknight days in this lifetime. The next free polyknight number is 267,598, the next one-sided polyknight number is 52,484 and the next fixed polyknight number is 209,608. 

For information on polykings, follow this link: https://mathworld.wolfram.com/Polyplet.html

Monday, 21 June 2021

Aliquot Sequences Revisited

I only have one post dealing with Aliquot Sequences and that eponymous post appeared on December 20th 2017 with an update on July 17th 2020. Let's recall that an aliquot sequence is:

A sequence of positive integers in which each term is the sum of the proper divisors of the previous term. If the sequence reaches the number 1, it ends, since the sum of the proper divisors of 1 is 0.

On December 20th 2017, I turned 25908 days old and this number is a member of OEIS A008888:


 A008888

Aliquot sequence starting at 138.                              


The reason for my update on July 17th 2020 is that on that day I turned 26038 days old and this number is also a member of OEIS A008888 but it appears near the end of the sequence instead of at the beginning like 25908. Here is the full sequence with the two numbers marked in bold:
138, 150, 222, 234, 312, 528, 960, 2088, 3762, 5598, 6570, 10746, 13254, 13830, 19434, 20886, 21606, 25098, 26742, 26754, 40446, 63234, 77406, 110754, 171486, 253458, 295740, 647748, 1077612, 1467588, 1956812, 2109796, 1889486, 953914, 668966, 353578, 176792, 254128, 308832, 502104, 753216, 1240176, 2422288, 2697920, 3727264, 3655076, 2760844, 2100740, 2310856, 2455544, 3212776, 3751064, 3282196, 2723020, 3035684, 2299240, 2988440, 5297320, 8325080, 11222920, 15359480, 19199440, 28875608, 25266172, 19406148, 26552604, 40541052, 54202884, 72270540, 147793668, 228408732, 348957876, 508132204, 404465636, 303708376, 290504024, 312058216, 294959384, 290622016, 286081174, 151737434, 75868720, 108199856, 101437396, 76247552, 76099654, 42387146, 21679318, 12752594, 7278382, 3660794, 1855066, 927536, 932464, 1013592, 1546008, 2425752, 5084088, 8436192, 13709064, 20563656, 33082104, 57142536, 99483384, 245978376, 487384824, 745600776, 1118401224, 1677601896, 2538372504, 4119772776, 8030724504, 14097017496, 21148436904, 40381357656, 60572036544, 100039354704, 179931895322, 94685963278, 51399021218, 28358080762, 18046051430, 17396081338, 8698040672, 8426226964, 6319670230, 5422685354, 3217383766, 1739126474, 996366646, 636221402, 318217798, 195756362, 101900794, 54202694, 49799866, 24930374, 17971642, 11130830, 8904682, 4913018, 3126502, 1574810, 1473382, 736694, 541162, 312470, 249994, 127286, 69898, 34952, 34708, 26038, 13994, 7000, 11720, 14740, 19532, 16588, 18692, 14026, 7016, 6154, 3674, 2374, 1190, 1402, 704, 820, 944, 916, 694, 350, 394, 200, 265, 59, 1, 0

Today is different however, because 26376 (my diurnal age on the date of this post) is not a member of a terminating aliquot sequence like OEIS A008888 but instead it is a member of an aliquot sequence for which it has not yet been determined whether there is an end or an eventual repetition. The sequence is OEIS A014361:


 A014361

Aliquot sequence starting at 564.                            


The initial members of this sequence are 564, 780, 1572, 2124, 3336, 5064, 7656, 13944 and 26376. Numbers like 564 form their own sequence and that is OEIS A131884:


 A131884

Numbers conjectured to have an infinite, aperiodic, aliquot sequence.        


The initial members of this sequence are:
276, 306, 396, 552, 564, 660, 696, 780, 828, 888, 966, 996, 1074, 1086, 1098, 1104, 1134, 1218, 1302, 1314, 1320, 1338, 1350, 1356, 1392, 1398, 1410, 1464, 1476, 1488, 1512, 1560, 1572, 1578, 1590, 1632, 1650, 1662, 1674, 1722, 1734, 1758, 1770, 1806, 1836

So I thought that today's number with its membership of a rather exclusive club was worth a mention.

Odds and Evens: Statistics

 This post won't make much sense unless my previous posts on this topic are read:


Figure 1

Figure 1 shows the sums of odd and even digits in the number systems from 10 down to 2. It also shows the ratio between the two sums. With even bases (10, 8, 6, 4 and 2), it can be seen that the sum of odd digits are larger than the sum of even digits. With odd bases (9, 7, 5 and 3), the situation is reversed.

In my previous post on Binary Odds and Evens, it was apparent that no vortices were possible and thus there were only captives and attractors. In base 10, captives could be captured by attractors and vortices. This same situation should prevail in the bases from 9 down to 3. However, the main focus of this post is to look at the first 100,000 integers and enumerate them according to the nomenclature that I have developed. What I discovered is that there are:
  • 3725 attractors
  • 58977 captives of these attractors
  • 914 vortices with a total of 3975 vorticals
  • 34223 captives of these vortices
Figure 1 shows a graphical representation of this data:

Figure 1: link

The average number of vorticals in a vortex is almost exactly four. The maximum size of a vortex in the range chosen is 11 and there are two of these:
  • 81191, 81193, 81195, 81197, 81199, 81201, 81203, 81204, 81205, 81207, 81211 
  • 18211, 18191, 18193, 18195, 18197, 18199, 18201, 18203, 18204, 18205, 18207
The minimum size is of course is two and there are many of these e.g. 198 --> 200 --> 198. 


Here is a permalink to the SageMathCell program that calculated this information. I did need to do a fair bit of tinkering to get it all to work but I'm very pleased with the final result.

Saturday, 19 June 2021

Binary Odds and Evens


In my earlier post, titled Odds and Evens, I investigated what happened to decimal numbers when the odd-even recursive process was applied to them. In this process, the sum of a number's odd digits is added to the number and the sum of its even digits subtracted. In those numbers where the sum of the odd and even digits is equal, the number remains unchanged by this process and is termed an attractor, using the nomenclature that I developed. 112 is the first such number and any permutations of the digits of an attractor are also attractors. Thus 112 and 211 are also attractors. Less than 4% of numbers are of this types.

Most numbers are what I termed captives and the process leads them to either an attractor or a vortex. The steps in this process are termed its trajectory and as an example, let's use 5. It's trajectory is 5, 10, 11, 13, 17, 25, 28, 18 because the final number, 18, leads back to 11. The sequence of numbers 11, 13, 17, 25, 28, 18 constitutes a vortex from which there is no escape. On the other hand, 145 has a trajectory of 145, 147, 151, 158, 156 because 156 is an attractor and so no further change is possible. In my last post, titled Attractors, Vortices and Captives, I explored the odd-even decimal universe in more detail.


Figure 1: 150 is an attractor in binary but not in decimal

Once we use binary numbers however, a fundamental difference arises when the odd-even recursive process is applied. There are only 1's and 0's with the former being odd and thus are added while the latter, even though even, don't contribute. Thus there can be no vortices because return to an earlier number is not possible. The process always lead to increasingly bigger numbers and the process will never end. If we don't want the process to go on forever, then some intervention is necessary. One way to terminate the process is to stop when an equal number of 1's and O's is reached. If a number already has this balance then it is an attractor and remains unchanged. This is the approach followed in this post. At the end of this post, I'll suggest another approach.

This is a fundamentally different process. See Figure 1. If applied to decimal numbers, it would mean that a number like 201334 would be an attractor because it has three even digits and three odd digits, even though the sum of the odd digits is 7 and the sum of the even digits is 6. However, the process can be modified to accommodate our binary problem. We could say:

  1. For non-binary number systems, an attractor is defined as a number whose sum of even and odd digits is equal. The odd-even recursive process, as applied to non-binary numbers that are not attractors, is to add the sum of the odd digits and subtract the sum of the even digits so that a new number is generated. This process is repeated until an attractor is reached or the numbers enters a vortex, or endless loop of numbers.

  2. For the binary number system, an attractor is defined as a number with the same number of 1's and 0's. The odd-even recursive process, as applied to binary numbers that are not attractors, is to add the sum of the 1's so that a new number is generated. This process is repeated until an attractor is reached. Vortices are not possible in the binary number system.

Let's use 2149 as an example. As a binary number its trajectory would be:

100001100101, 100001101010, 100001101111, 100001110110

This number has a trajectory of length 3 because 100001110110 is an attractor, having an equal number of 1's and 0's. This attractor in decimal form is 2166. Some numbers take quite a few steps to reach an attractor. 243 is an example of such a number because it takes 59 steps to reach the attractor 527. I've created an algorithm to look at the first 30,000 numbers and I've discovered that the record is set by 15998 with a trajectory of length of 2228 steps, leading to a final number of 33231 (an attractor in the binary number system). Here is a permalink to that program.

In the range between 1 and 30000, attractors total 2353 or 7.84% while there are 27646 captives representing 92.16%.

I mentioned that I'd propose an alternative approach to the odd-even recursive process as applied to binary numbers. This approach involves treating 0's as -1 and 1's as simply 1's. Thus a binary number like 10010110 shown in Figure 1 would still be an attractor but vortices are now possible because of subtraction and these could draw in numbers in the same way that attractors do. The downside is that it treats 0's quite differently than in the higher bases. I'll try to investigate this approach in a future post.

Friday, 18 June 2021

Attractors, Vortices and Captives

 Regarding my previous post, I'm inclining toward the following nomenclature:

  • an attractor to describe a number that is invariant under the odd-even recursive process

  • a vortex to describe an loop involving two or more numbers under the process

  • a vortical to describe a number that forms part of a vortex

  • a captive to describe a number that eventually leads to an attractor or a vortex

  • N-captive to describe a number that is captive to a number N that is either an attractor or the smallest member of a vortex
The trajectory of 710 leads directly to the attractor 718 so i710 can be described as a 718-captive. The trajectory of 719 leads to 719, 736, 740, 743, 749, 761, 763, 767, 775, 794, 806, 792, 806 and is thus captured by the 792-806 vortex. As a convention, I'll choose the smallest vortical to identify the vortex (although any vortical would do) and so 719 becomes a 792-captive

It's clear from the leading number whether the number to captive to an attractor or a vortex but a subscript could be optionally added for numbers with a large number of digits. Thus we could write 718\( _a \)-captive and 782\( _v \)-captive.

Attractors can be visualised as having a solid central core (the attractor itself) with various spokes corresponding to the captives attached to it. For example, 718 is an attractor with four captives: 710, 712, 714 and 716. Each of these four captives is only one step removed from the attractor. This can be represented as shown in Figure 1.

Figure 1: 718 is an attractor with four captives

Some attractors have no captives. For example, in the range from 690 to 889, there are only six attractors: 718, 781, 817, 835, 853 and 871. Of these, only 718 has any captives. On the other hand, some attractors like 87980 with 881 captives can be termed great attractors.

Meanwhile, in the aforementioned range from 690 to 889, every number (apart from the six attractors and four captives) is captive to the small but powerful vortex: 792-806. These two numbers are vorticals and together make up the vortex. Such a vortex could be represented as shown in Figure 2.


Figure 2: the vortex 792-806

A vortex can be shown with its captives attached, although there are too many to show in the case of 792-806. All captives shown can be described as 792-captives. See Figure 3.

Figure 3: vortex, vorticals and captives

Attractors in general could be represented by A and would be equivalent to the number itself and could be differentiated by their subscripts \(A_1, A_2, \dots \). Thus we could write \(A_1=\left \{718 \right \} \). An attractor can also be associated with the set of its captives. For example, an attractor \(A_1\) with \(n\) captives could be associated with the set \(C_1\) such that:$$C_1=\left \{c_1, c_1, \dots , c_{n-1}, c_n \right \}$$ A particular example is \(C_1= \left \{710, 712, 714, 716 \right \} \) where \(A_1= \left \{ 718 \right \} \).

A vortex could be represented by V and would be equivalent to the set of its vorticals v. Thus for a particular vortex \(V_1\), with \(n\) vorticals, could be written as:$$V_1=\left \{ v_1, v_2, \dots , v_{n-1},v_n \right \}$$A particular example would be \(V_1=\left \{792, 806 \right \} \).

A vortex is also associated with the set of its captives and so a particular vortex \(V_1\) with \(n\) captives could be associated with the set \(C_2\) such that:$$C_2=\left \{c_1, c_1, \dots , c_{n-1}, c_n \right \}$$That's about it for this post. I just wanted to establish a consistent and readily understandable notational system. I'm just developing this as I go so there may well be future modifications.

Thursday, 17 June 2021

Odds and Evens

Today, having turned 26372 days old, I set out finding something interesting about this number. There wasn't anything that caught my attention until I stumbled upon the information shown in Figure 1.


Figure 1

The site link that is displayed refuses to load but the purple print piqued my curiosity:

Add to n its odd digits and subtract its even ones

I realised that 26372 is special in this regard because its odd digits (3 and 7) add to 10 and its even digits (2, 6 and 2) also add to 10. The number is unaffected by this process of addition and subtraction. It might be termed stable under this process. What about other numbers that aren't stable? How many repetitions of the process are needed on average for a number to become a stable number? Are there some numbers that never become stable? What proportion of numbers are stable? That's what I set out to investigate in a SageMath program that examined the first 100,000 integers. Here is a permalink to that program. 

The output reveals that 88985, 88987 and 91055 produce record runs of 81 steps before reaching a stable number. The average run or trajectory length is 8.58. Figure 1 shows a plot of all trajectory lengths for numbers from 1 to 100000.


Figure 1: permalink

So how many numbers are stable in that range. Here is a permalink to another SageMath program that determines this. The answer turns out to 3725 or 3.725% of the numbers between 1 and 100,000. In the range from 1 to 1000, the numbers are:

112, 121, 134, 143, 156, 165, 178, 187, 211, 314, 336, 341, 358, 363, 385, 413, 431, 516, 538, 561, 583, 615, 633, 651, 718, 781, 817, 835, 853, 871

These numbers form OEIS  A036301 but there is no further analysis done.


 A036301

Numbers whose sum of even digits and sum of odd digits are equal. 

Of the 3725 numbers between 1 and 100000 that are member of OEIS A036301, 301 are prime. Here is a permalink to a program that will verify this.

I wrote another program that displays the "trajectory" or path of a number on its journey from instability to stability or looping. Here is a permalink to this program. Applied to 88985, it can be seen that the trajectory is:

88985, 88975, 88980, 88965, 88957, 88962, 88947, 88943, 88935, 88936, 88926, 88911, 88906, 88893, 88881, 88850, 88831, 88811, 88789, 88781, 88765, 88755, 88756, 88746, 88727, 88723, 88715, 88712, 88702, 88691, 88679, 88673, 88661, 88634, 88611, 88591, 88590, 88588, 88561, 88545, 88535, 88532, 88522, 88507, 88503, 88495, 88489, 88470, 88457, 88449, 88434, 88413, 88397, 88400, 88380, 88359, 88360, 88341, 88325, 88315, 88308, 88287, 88268, 88236, 88215, 88203, 88188, 88157, 88154, 88140, 88121, 88105, 88095, 88093, 88089, 88074, 88061, 88040, 88020, 88002, 87984, 87980, 87980

After 81 steps, the stable number 87980 is reached. The table in Figure 2 shows that the numbers near 88985 and 88987 have mostly near-record trajectory lengths.


Figure 2

However, Figure 3 shows that 91055 is very much a singleton.


Figure 3

If the range is extended to 200,000, a new record of 91 is reached with 158893. The trajectory is:

158893, 158895, 158899, 158907, 158921, 158927, 158939, 158958, 158962, 158961, 158963, 158967, 158975, 158994, 159006, 159015, 159036, 159048, 159051, 159072, 159092, 159114, 159127, 159148, 159152, 159171, 159195, 159225, 159241, 159251, 159270, 159290, 159312, 159329, 159354, 159373, 159401, 159413, 159428, 159429, 159447, 159461, 159467, 159479, 159506, 159520, 159538, 159553, 159581, 159594, 159619, 159638, 159642, 159645, 159655, 159674, 159686, 159681, 159683, 159687, 159695, 159718, 159733, 159761, 159778, 159799, 159839, 159858, 159862, 159861, 159863, 159867, 159875, 159894, 159906, 159924, 159942, 159960, 159978, 160001, 159997, 160037, 160042, 160031, 160030, 160028, 160013, 160012, 160006, 159995, 160033, 160034, 160028

Interestingly, a stable number is not reached but instead a loop arises: 160028, 160013, 160012, 160006, 159995, 160033, 160034, 160028. So some numbers attain "stability" (such as 88985) while others enter a loop (such as 158893). 

Figure 4 is a plot of all trajectory lengths from 1 to 200,000:


Figure 4

Note that the average trajectory length has increased from 8.58 to 10.6 which makes sense. As numbers get bigger, it should take them longer to settle on a stable number or to enter a loop. It's difficult to explore beyond 200,000 because SageMathCell times out. 

I developed another algorithm to check on the relative proportions of numbers that end up as stable numbers versus ending in a loop. Here is a permalink. The results are as follows:

  • total of numbers ending in a stable number is 58977 up to 100000 or 59.0 percent
  • total of numbers ending in loop is 37298 up to 100000 or 37.3 percent
  • total number of stable numbers up to 100000 is 3725 or 3.73 percent
Figure 5 shows a graphical representation:

Figure 5

One general point to note about this odd-even recursive process is that there are five odd digits (1, 3, 5, 7 and 9) totalling 25 and four even digits (2, 4, 6 and 8) totalling 20. The process thus favours the progressive numbers getting larger rather than smaller. 

Some stable numbers attract unstable numbers far more strongly than others. Figure 6 shows a table listing the top "attractors". As can be seen, 87980 might be termed the Great Attractor with 881 unstable numbers being attracted to it. Here is a permalink to the program that created the information.


Figure 6: Google Sheet Link

Looking at all the data in the spreadsheet, 134 stands out because even though it is a small number, it attracts 74 unstable numbers.

Overall, it's clear than in terms of this odd-even recursive process there are three types of numbers:
  • numbers that remain unchanged by the process e.g. 112. 
  • numbers that are changed by the process and in the end become unchangeable numbers e.g. 114 becomes 112 in only one step of the process.
  • numbers that are changed by the process and in the end become trapped in a loop e.g. 5 which has a trajectory of 10, 11, 13, 17, 23, 24, 18, 11 and so becomes caught in a loop and never becomes an unchangeable.
We might call the first type of number immutable and the two other types mutable but differentiated by a prefix i-mutable and v-mutable where v stands for vortex (that these types of numbers are drawn into). So 112 could be described as an immutable number, 114 as i-mutable and 5 as v-mutable. These differentiators are speculative and might change but they do serve to clearly identify each type of number.

Another nomenclature that I considered was that of attractor and captive. It's as if the gravitational pull of an attractor (an immutable number in my previous nomenclature) pulls the i-mutable numbers to them and so in a sense they are captives of the attractor. The v-mutable numbers are also attracted by the vortices comprised of a series to two or more looping chains of numbers, each member of which might be termed a vortical. This could be explained as follows:
  • 112 is an attractor
  • 114 is a captive of the attractor 112
  • 5 is a captive of the vortex {10, 11, 13, 17, 23, 24, 18}
  • 10, 11, 13, 17, 23, 24 and 18 are vorticals comprising the vortex
In the past, my first response to a number was to consider whether it was prime or composite whereas now I'll be inclined to also consider whether it's mutable or immutable and, if the former, whether it is i-mutable or v-mutable OR I might just settle on attractor, captive and vortical.

Wednesday, 16 June 2021

Primes from Primes

I've begun reading "The Man Who Loved Only Numbers" by Paul Hoffman, a biography of Paul Erdƶs. Figure 1 shows the front cover of the book. It motivated me to be a little more energetic in my daily number analysis at least for today because today was a prime day.

Figure 1


THE STORY OF PAUL ERDƖS AND THE SEARCH FOR MATHEMATICAL TRUTH

***

By that I mean I turned a prime number of days old, specifically 26371. Initially, I'd found that this number was a member of OEIS A255543:


  A255543

Unlucky array: Row \(n\) consists of unlucky numbers removed at the stage \(n\) of Lucky sieve.


Figure 2, taken from the OEIS entry comments, shows what is meant by this:


Figure 2

Looking at the first row, it can seen that 2 and all multiples of 2 are removed. In the second row, every third remaining number is removed and so on for successive rows. 26371 lies in the 29th row that lists all the numbers removed when every 29th number is struck off. This was interesting but didn't relate to any specific properties of 26371 as a prime number. A little more research, motivated by Erdƶs's indefatigable research, led me to OEIS A249350:


 A249350

Prime numbers Q such that the concatenation Q, 6, Q is prime.   
           

As a member of this sequence, 26371 has the property that 26371626371 is a prime number. Up to 26371, the list of such primes is:
[13, 23, 29, 41, 53, 59, 71, 73, 89, 107, 149, 167, 173, 197, 239, 241, 257, 293, 349, 379, 383, 397, 439, 457, 461, 479, 503, 521, 547, 569, 607, 617, 631, 643, 677, 691, 727, 733, 757, 821, 887, 919, 941, 947, 953, 967, 1051, 1061, 1069, 1097, 1103, 1187, 1213, 1217, 1237, 1279, 1297, 1373, 1399, 1409, 1423, 1433, 1451, 1453, 1471, 1483, 1499, 1567, 1609, 1619, 1621, 1667, 1709, 1721, 1723, 1783, 1787, 1789, 1861, 1867, 1889, 1913, 1993, 1997, 2011, 2017, 2029, 2063, 2099, 2113, 2251, 2269, 2273, 2357, 2393, 2441, 2473, 2503, 2557, 2609, 2647, 2657, 2659, 2687, 2699, 2711, 2713, 2777, 2843, 2897, 2927, 2953, 3037, 3061, 3079, 3137, 3217, 3271, 3323, 3343, 3499, 3511, 3527, 3547, 3557, 3593, 3631, 3659, 3673, 3733, 3779, 3851, 3911, 4051, 4093, 4129, 4241, 4243, 4253, 4327, 4339, 4373, 4391, 4457, 4493, 4519, 4561, 4583, 4597, 4603, 4639, 4643, 4663, 4723, 4787, 4789, 4801, 4813, 4877, 4933, 4951, 4967, 5011, 5023, 5051, 5179, 5209, 5333, 5413, 5527, 5557, 5647, 5807, 5851, 5857, 5867, 5903, 6067, 6113, 6173, 6199, 6311, 6353, 6379, 6553, 6571, 6659, 6781, 6827, 6841, 6871, 6949, 6997, 7013, 7079, 7151, 7177, 7193, 7237, 7349, 7393, 7459, 7481, 7523, 7529, 7541, 7559, 7573, 7589, 7607, 7621, 7673, 7687, 7793, 7817, 7823, 7841, 7867, 7873, 7907, 8087, 8093, 8101, 8209, 8317, 8369, 8387, 8419, 8429, 8447, 8461, 8467, 8573, 8623, 8647, 8677, 8681, 8699, 8741, 8779, 8803, 8821, 8861, 8971, 8999, 9013, 9059, 9133, 9137, 9181, 9199, 9239, 9283, 9337, 9343, 9419, 9431, 9461, 9473, 9511, 9533, 9539, 9629, 9767, 9883, 10103, 10133, 10223, 10357, 10487, 10559, 10691, 10729, 10847, 10853, 10909, 10957, 10979, 11083, 11093, 11117, 11159, 11177, 11243, 11273, 11321, 11329, 11369, 11393, 11471, 11483, 11489, 11491, 11813, 11887, 12007, 12049, 12119, 12211, 12239, 12253, 12281, 12289, 12379, 12413, 12479, 12517, 12527, 12553, 12647, 12703, 12721, 12889, 12919, 13003, 13037, 13043, 13147, 13163, 13171, 13381, 13499, 13679, 13757, 13877, 14009, 14051, 14057, 14071, 14081, 14207, 14423, 14449, 14627, 14723, 14767, 14813, 14869, 14879, 14939, 15031, 15061, 15101, 15131, 15173, 15193, 15299, 15373, 15377, 15383, 15541, 15559, 15629, 15643, 15649, 15787, 15877, 15919, 15923, 16189, 16333, 16339, 16361, 16427, 16487, 16529, 16607, 16649, 16763, 16871, 16903, 16931, 17011, 17021, 17029, 17033, 17077, 17137, 17419, 17483, 17729, 17747, 17749, 17851, 17903, 17921, 17957, 17981, 18041, 18049, 18169, 18257, 18397, 18413, 18517, 18541, 18583, 18671, 18691, 18701, 18719, 18749, 18757, 18803, 18973, 19069, 19211, 19213, 19289, 19379, 19463, 19471, 19489, 19603, 19819, 19843, 19861, 19919, 20071, 20101, 20147, 20261, 20297, 20399, 20443, 20681, 20707, 20731, 20849, 20897, 20921, 20939, 21001, 21011, 21059, 21089, 21121, 21163, 21169, 21221, 21227, 21313, 21341, 21401, 21407, 21467, 21523, 21569, 22109, 22129, 22171, 22247, 22349, 22639, 22643, 22741, 22769, 22787, 22811, 22961, 23027, 23041, 23143, 23201, 23203, 23339, 23357, 23369, 23459, 23537, 23627, 23629, 23747, 23767, 23819, 23857, 23879, 23887, 24007, 24019, 24029, 24061, 24097, 24151, 24391, 24407, 24421, 24683, 24767, 24851, 24953, 25033, 25147, 25253, 25321, 25439, 25643, 26119, 26189, 26237, 26357, 26371]

26371 is the 2897th prime and the primes listed above total 502. This means that of all the primes up 26371, 502 or about 16.8% generate a new prime according the Q + 6 + Q concatenation. I wondered what numbers arise when the digits 1, 2, 3, 4, 5, 7, 8 and 9 are used instead. Inserting 0 between the two primes cannot produce a prime because the resulting concatenated number is always divisible by Q. Here are the figures for the digits from 1 to 9:

1     278
2     238
3     528
4     242
5     258
6     502
7     296
8     247
9     512

total is 3101

It can be seen that the record is held by the digit 3, although 6 and 9 are close behind. Well back however, are the digits 1, 2, 4, 5, 7 and 8. I thought I'd extend this to the first one million primes and Figure 3 shows the results obtained:


Figure 3

The proportions remain about the same with the exception of the digit 7. Figure 4 shows a table summarising the results:


Figure 4

Why do the digits 3, 6 and 9 produce about twice as many primes as the digits 1, 2, 4, 5 and 8? Why does the digit 7 produce significantly fewer primes that 1, 2, 4, 5 and 8? These are questions that I don't know the answer to but I'm keen to investigate.

One doesn't have to stop at the digit 9. What happens for the digits 10 to 19? Figure 5 tells the tale.


Figure 5

Figure 6 shows the same results in tabular form. It's clear that the multiples of 3 (12, 15 and 18) always win the day and with consistent frequency. The digits 10, 16 and 17 produce about half as many primes as their multiple of 3 counterparts, while 11, 13, 14 and 19 produce less than a third of even this number.


Figure 6

One might surmise that the frequency for multiples of 3 remains relatively constant as we investigate higher digits. After all, the numbers for 3, 6, 9, 12, 15 and 18 have been quite consistent. However, 21 = 3 x 7 breaks the pattern. See Figure 7.


Figure 7

The figure for 21 is not as low as for 22, 26 and 28 but it significantly lower than even the figures for 20, 23, 25 and 29. Figure 8 presents the results in tabular form.


Figure 8

Multiples of 7, 11 and 13 seem to produce far fewer primes when concatenated using Q + digit + Q. Figure 9 provides an overview of the digits from 1 to 99:


Figure 9

Clearly, there is more to be discovered here but I'll finish up at this point. What this post teaches us more than anything else is to not let a good prime go to waste and to be a little more energetic in my investigations.