Saturday, 11 September 2021

Displaying the SageMathCell Interface

Quite some time ago I tried embedding the SageMathCell interface in my blog posts but experienced some glitches that led me to turn to the use of permalinks as an alternative. The permalink is almost as good as having the interface embedded but it does require the user to click a hyperlink. There's something to be said for simple embedding as the user can execute the SageMath code right there on the page without following a hyperlink. In this post I just want to test this method out again, using a sequence from my previous post:


 A279093

Numbers that are nontrivially palindromic in three or more consecutive integer bases.

The initial members are:

178, 300, 373, 676, 1111, 1702, 2473, 3448, 4651, 6106, 7837, 9868, 12223, 14926, 18001, 21472, 25363, ...

Pressing evaluate in the embedded SageMathCell interface should produce "the initial members" as listed under the sequence. Now I'll take it a step further and display numbers along with their palindromic equivalents in the three consecutive number bases.


Thursday, 9 September 2021

Palindromes In Two Or More Consecutive Number Bases

Having turned a venerable 26457 days old, I searched through the OEIS to find an interesting sequence in which this number appeared. Nothing caught my fancy but I did stumble upon an interesting post to the Mathematics section of StackExchange. See Figure 1.


Figure 1

An extended search within the OEIS, looking for so-called b-files (see my December 2019 article titled In the Groove), had revealed nothing of interest but Google had returned a result because the number appeared in the StackExchange post and that post contained links to the OEIS. The post began as follows:
Lets look at sequences of numbers that are a palindromic number in two consecutive number bases \(b\) and \(𝑏+1\), where \(𝑏 \geq 2\) of course. (And also ignoring trivial one digit palindromes.)

I would conjecture that there are infinitely many numbers palindromic in two consecutive number bases for any two number bases \((𝑏,𝑏+1)\) where \(b \geq 2\). But I do not know how to show that this statement is true.

Turns out, it is in fact not known if the case \((2,3)\) for example, has infinitely many terms, since the OEIS entry for it is written as "...if it exists". There are no clear patterns in this particular sequence, as it seems.
This is the OEIS entry referred to:


 A060792

 Numbers that are palindromic in bases 2 and 3.     

The first few entries are: 0, 1, 6643, 1422773, 5415589, 90396755477, ... so such numbers are relatively sparse. Looking at the first non-trivial number in this sequence (6643), we see that in base 2, 6643 --> 1100111110011 and in base 3, 6643 --> 100010001.

The StackExchange goes on to list numbers that are palindromic is two consecutive number bases (with \( b\) ranging from 2 to 36):

Numbers up to 107 in number bases up to 32 (where the ∗ indicates that the number is also palindromic in a third consecutive base) :

(2, 3): 6643, 1422773, 5415589, ... OEIS A060792

(3, 4): 10, 130, 11950, 175850, 749470, 1181729, ... OEIS A097928

(4, 5): 46, 9222, 76449, 193662, 2347506, 2593206, ... OEIS A097929

(5, 6): 67, 98, 104, 651, 2293, 3074, 26691, 27741, 704396, 723296, 755846, 883407, ... OEIS A097930

(6, 7): 92, 135, *178, 185, 5854, 6148, 7703, 186621, 204856, 206620, 213970, 269957, 271721, 279071, ... OEIS A097931

(7, 8): 121, 178, 235, 292, *300, 2997, 6953, 7801, 10658, 13459, 16708, 428585, 431721, 444713, 447849, ... OEIS A099145

(8, 9): 154, 227, 300, *373, 446, 455, 11314, 12547, 17876, 27310, 889435, 894619, 899803, 926371, ... OEIS A099146

(9, 10): 191, 282, 373, 464, 555, 646, 656, 6886, 25752, 27472, 42324, 50605, 626626, 1540451, 1713171, 1721271, 1828281, 1877781, 1885881, 2401042, 2434342, 2442442, 2450542, 3106013, 3114113, 3122213, 3163613, 3171713, 3303033, *3360633, ... OEIS A029965

(10, 11): 232, 343, 454, 565, *676, 787, 898, 909, 26962, 38183, 40504, 49294, 52825, 63936, 75157, 2956592, 2968692, 3262623, 3274723, 3286823, 3298923, 3360633, 3372733, 4348434, 4410144, 4422244, 4581854, 4593954, 5643465, 5655565, 5667665, 5741475, 7280827, 7292927, 8710178, 8722278, 8734378, 8746478, 8758578, 8820288, 8832388, ... OEIS A029966

(11, 12): 277, 410, 543, 676, 809, 942, 1075, 1208, 1220, 38425, 54662, 72351, 75399, 93088, 125430, 1798303, 1817179, 5058385, 5075809, 5093233, 5199361, 5216785, 5550889, 5568313, 5585737, 5603161, 5620585, 7569434, 7727702, 7833830, 7851254, 7868678, 7886102, 9711399, 9728823, 9746247, 

(12, 13): 326, 483, 640, 797, 954, *1111, 1268, 1425, 1582, 1595, 53210, 100636, 104549, 123257, 129198, 151819, 174596, 227806, 8281118, 8305454, 8329790, 8354126, 8502170, 8526506, 9041475, 9065811, 9090147, 9114483, 

(13, 14): 379, 562, 745, 928, 1111, 1294, 1477, 1660, 1843, 2026, 2040, 71905, 105394, 136517, 167458, 170006, 174934, 205875, 208423, 239364, 270487, 342392, 344954, 

(14, 15): 436, 647, 858, 1069, 1280, 1491, *1702, 1913, 2124, 2335, 2546, 2561, 95146, 139667, 181248, 225769, 231874, 267140, 276395, 317766, 454493, 499014, 502179, 

(15, 16): 497, 738, 979, 1220, 1461, 1702, 1943, 2184, 2425, 2666, 2907, 3148, 3164, 123617, 181698, 294260, 348501, 359797, 414038, 472119, 526600, 650217, 708298, 712154, 

(16, 17): 562, 835, 1108, 1381, 1654, 1927, 2200, *2473, 2746, 3019, 3292, 3565, 3838, 3855, 158050, 232579, 307108, 377285, 447190, 451814, 460807, 521719, 530712, 535336, 605241, 679770, 833468, 907997, 977902, 982526, 987167, 

(17, 18): 631, 938, 1245, 1552, 1859, 2166, 2473, 2780, 3087, 3394, 3701, 4008, 4315, 4622, 4640, 199225, 293474, 387723, 476770, 571019, 659760, 675996, 764737, 858986, 1147258, 1241507, 1330248, 1341282, 

(18, 19): 704, 1047, 1390, 1733, 2076, 2419, 2762, 3105, *3448, 3791, 4134, 4477, 4820, 5163, 5506, 5525, 247970, 365619, 483268, 712410, 823561, 842732, 941210, 953883, 1071532, 1189181, 1430995, 1548644, 1666293, 1777444, 

(19, 20): 781, 1162, 1543, 1924, 2305, 2686, 3067, 3448, 3829, 4210, 4591, 4972, 5353, 5734, 6115, 6496, 6516, 305161, 450322, 595483, 740644, 878585, 1016146, 1023746, 1161307, 1176147, 1183747, 1321308, 1466469, 1611630, 1909571, 2054732, 2192293, 2199893, 2337454, 2352294, 

(20, 21): 862, 1283, 1704, 2125, 2546, 2967, 3388, 3809, 4230, *4651, 5072, 5493, 5914, 6335, 6756, 7177, 7598, 7619, 371722, 548963, 726204, 903445, 1072286, 1249527, 1417948, 1444009, 1595189, 1612430, 1789671, 1966912, 2330234, 2507475, 2684716, 2853137, 3030378, 3047619, 

(21, 22): 947, 1410, 1873, 2336, 2799, 3262, 3725, 4188, 4651, 5114, 5577, 6040, 6503, 6966, 7429, 7892, 8355, 8818, 8840, 448625, 662994, 877363, 1091732, 1510768, 1714973, 1929342, 1949230, 2163599, 2377968, 2592337, 3031260, 3245629, 3459998, 3664203, 3878572, 3898460, 

(22, 23): 1036, 1543, 2050, 2557, 3064, 3571, 4078, 4585, 5092, 5599, *6106, 6613, 7120, 7627, 8134, 8641, 9148, 9655, 10162, 10185, 536890, 793939, 1050988, 1308037, 1565086, 1811003, 2056414, 2068052, 2313463, 2347894, 2570512, 2593305, 2850354, 3107403, 3364452, 3633161, 3890210, 4147259, 4392670, 4404308, 4649719, 4906768, 4929561, 

(23, 24): 1129, 1682, 2235, 2788, 3341, 3894, 4447, 5000, 5553, 6106, 6659, 7212, 7765, 8318, 8871, 9424, 9977, 10530, 11083, 11636, 11660, 637585, 943394, 1249203, 1555012, 1860821, 2153934, 2459743, 2752304, 3058113, 3084081, 3389890, 3695699, 4001508, 4626397, 4932206, 5238015, 5530576, 5836385, 6142194, 6168162, 

(24, 25): 1226, 1827, 2428, 3029, 3630, 4231, 4832, 5433, 6034, 6635, 7236, *7837, 8438, 9039, 9640, 10241, 10842, 11443, 12044, 12645, 13246, 13271, 751826, 1113027, 1474228, 1835429, 2196630, 2904632, 3250833, 3612034, 3973235, 4002660, 4363861, 4725062, 5086263, 5462488, 5823689, 6184890, 6546091, 6892292, 7253493, 7614694, 7644119, 

(25, 26): 1327, 1978, 2629, 3280, 3931, 4582, 5233, 5884, 6535, 7186, 7837, 8488, 9139, 9790, 10441, 11092, 11743, 12394, 13045, 13696, 14347, 14998, 15024, 880777, 1304578, 1728379, 2152180, 2575981, 2999782, 3407333, 3814234, 3831134, 4238035, 4661836, 4695012, 5118813, 5542614, 5966415, 6830942, 7254743, 7678544, 8085445, 8102345, 8509246, 8933047, 9356848, 9390024, 

(26, 27): 1432, 2135, 2838, 3541, 4244, 4947, 5650, 6353, 7056, 7759, 8462, 9165, *9868, 10571, 11274, 11977, 12680, 13383, 14086, 14789, 15492, 16195, 16898, 16925, 1025650, 1519859, 2014068, 2508277, 3002486, 3496695, 3972652, 4466861, 4942116, 5436325, 5930534, 5967767, 6461976, 6956185, 7450394, 7963583, 8457792, 8952001, 9446210, 9921465, 

(27, 28): 1541, 2298, 3055, 3812, 4569, 5326, 6083, 6840, 7597, 8354, 9111, 9868, 10625, 11382, 12139, 12896, 13653, 14410, 15167, 15924, 16681, 17438, 18195, 18952, 18980, 1187705, 1760754, 2333803, 2906852, 3479901, 4052950, 5178636, 5730517, 6303566, 6876615, 6918223, 7491272, 8064321, 8637370, 9804663, 

(28, 29): 1654, 2467, 3280, 4093, 4906, 5719, 6532, 7345, 8158, 8971, 9784, 10597, 11410, *12223, 13036, 13849, 14662, 15475, 16288, 17101, 17914, 18727, 19540, 20353, 21166, 21195, 1368250, 2029219, 2690188, 3351157, 4012126, 4673095, 5334064, 5972297, 6609718, 6633266, 7270687, 7931656, 8592625, 8638938, 9299907, 9960876, 

(29, 30): 1771, 2642, 3513, 4384, 5255, 6126, 6997, 7868, 8739, 9610, 10481, 11352, 12223, 13094, 13965, 14836, 15707, 16578, 17449, 18320, 19191, 20062, 20933, 21804, 22675, 23546, 23576, 1568641, 2327282, 3085923, 3844564, 4603205, 5361846, 6120487, 6853898, 7612539, 8345080, 9103721, 9862362, 9913722, 

(30, 31): 1892, 2823, 3754, 4685, 5616, 6547, 7478, 8409, 9340, 10271, 11202, 12133, 13064, 13995, *14926, 15857, 16788, 17719, 18650, 19581, 20512, 21443, 22374, 23305, 24236, 25167, 26098, 26129, 1790282, 2657043, 3523804, 4390565, 5257326, 6124087, 6990848, 8696470, 9534401, 

(31, 32): 2017, 3010, 4003, 4996, 5989, 6982, 7975, 8968, 9961, 10954, 11947, 12940, 13933, 14926, 15919, 16912, 17905, 18898, 19891, 20884, 21877, 22870, 23863, 24856, 25849, 26842, 27835, 28828, 28860, 2034625, 3020674, 4006723, 4992772, 5978821, 6964870, 7950919, 8936968, 9892265, 

(32, 33): 2146, 3203, 4260, 5317, 6374, 7431, 8488, 9545, 10602, 11659, 12716, 13773, 14830, 15887, 16944, *18001, 19058, 20115, 21172, 22229, 23286, 24343, 25400, 26457, 27514, 28571, 29628, 30685, 31742, 31775, 2303170, 3420419, 4537668, 5654917, 6772166, 7889415, 9006664, 

Right at the very end of the above list, under number bases \(b=32\) and \(b=33\), we find \(26457\).$$ \begin{align} 26457_{_{10}}&=\text{ pqp }_{_{32}}\\&=\text{ o9o }_{_{33}} \end{align}$$What this means is that with \(o=24, p=25, q=26\) we have:$$\begin{align} 26457 &=25 \times 32^2+26 \times 32+25\\ &=24 \times 33^2+9 \times 33+24 \end{align}$$These numbers in fact form OEIS A279092:


 A279092

Numbers that are nontrivially palindromic in two or more consecutive integer bases. 

The initial members are:

10, 46, 67, 92, 98, 104, 121, 130, 135, 154, 178, 185, 191, 227, 232, 235, 277, 282, 292, 300, 326, 343, 373, 379, 410, 436, 446, 454, 455, 464, 483, 497, 543, 555, 562, 565, 631, 640, 646, 647, 651, 656, 676, 704, 738, 745, 781, 787, 797, 809, 835, 858, 862

Notice that in the StackExchange list for \(b=32\) and \(b=33\), \(18001\) is marked with an asterisk and so \(b=34\) is included as well:$$\begin{align} 18001_{_{10}}&=\text{ hih }_{_{32}}\\&=\text{ ghg }_{_{33}} \\&=\text{ fjf }_{_{34}} \end{align}$$Extracting the numbers with asterisks in the above list (remember the ∗ indicates that the number is also palindromic in a third consecutive base), we get:

(06, 07): 178 --> 454 b=6, 343 b=7, 262 b=8

(07, 08): 300 --> 606 b=7, 454 b=8, 363 b=9

(08, 09): 373 --> 565 b=8, 454 b=9, 373 b=10

(09, 10): 3360633 --> 6281826 b=9, 3360633 b=10 1995991 b=11

(10, 11): 676 --> 676 b=10, 565 b=11, 484 b=12

(12, 13): 1111 --> 787 b=12, 676 b=13, 595 b=14

(14, 15): 1702 --> 898 b=14, 787 b=15, 6a6 b=16

(16, 17): 2473 --> 9a9 b=16, 898 b=17, 7b7 b=18

(18, 19): 3448 --> aba b=18, 9a9 b=19, 8c8 b=20

(20, 21): 4651 --> bcb b=20, aba b=21, 9d9 b=22

(22, 23): 6106 --> cdc b=22, bcb b=23, aea b=24

(24, 25): 7837 --> ded base=24, cdc b=25, bfb b=26

(26, 27): 9868 --> efe b=26, ded b=27, cgc b=28

(28, 29): 12223 --> fgf b=28, efe b=29, dhd b=30

(30, 31): 14926 --> ghg b=30, fgf b=31, eie b=32

(32, 33): 18001 --> hih b=32, ghg b=33, fjf b=34

These numbers make up OEIS A279093:


 A279093

Numbers that are nontrivially palindromic in three or more consecutive integer bases.

The initial members are:

178, 300, 373, 676, 1111, 1702, 2473, 3448, 4651, 6106, 7837, 9868, 12223, 14926, 18001, 21472, 25363, 29698, 34501, 39796, 45607, 51958, 58873, 66376, 74491, 83242, 92653, 102748, 113551, 125086, 137377, 150448, 164323, 179026, 194581, 211012, 228343, 246598

Here is a list of the first thousand such numbers. 

The comments to the OEIS entry include the statement that no numbers have been found that are palindromes in four successive bases. 130 is given as an example of a number that is palindromic in seven integer bases: $$11211_3 = 2002_4 = 202_8 = {\large aa}_{12} = 55_{25} = 22_{64} = 11_{129}$$but these bases do not include three consecutive integers, so 130 is not in the sequence. Incidentally, I'm creating this palindromic post on the 9th September 2021 and on the 12th September, the date can be written palindromically as 12/9/21.

Wednesday, 1 September 2021

Dali and the Unfolded Hypercube

Figure 1

In April of 1984, as a birthday present from my father, I acquired a TR-80 computer from Tandy with 32Kb of RAM and a keyboard but no disk drive. Data input and output were via a cassette tape. Display was via a connected TV. Using this I began my BASIC programming and one of my first creations was a simulation of a projectile being launched to hit a target. The essential formulae for the projectile's motion are:$$x(t)=v_0 \cos(\theta) \cdot t \text{ and } y(t)=v_0 \sin(\theta) \cdot t - 0.5 g t^2$$where we have:

  • \(x(t)\) is horizontal position of projectile after time \(t\) with \(x=0\) when \(t=0\)
  • \(y(t)\) is vertical position of projectile after time \(t\) with \(y=0\) when \(t=0\)
  • \(v_0\) is initial velocity at time \(t=0\)
  • \(\theta\) is angle of projection
  • \(g\) is deceleration due to gravity \(\approx \) -9.8 \(ms^{-2}\)
Figure 1 shows the situation with an angle of 60° and an initial velocity fo 6 \(ms^{-1}\). What has all this to do with unfolding hypercubes? Well, April of 1984 marked my return to Mathematics after a long absence. In August of that year, I began my training as a Mathematics teacher and one of the assigned projects was an assignment on some aspect of Mathematics. I chose Mathematics and Art, a choice which led to me to the unfolded hypercube. In the University library, I came across Salvator Dali's 1954 Crucifixion (Corpus Hypercubus). See Figure 2.


Figure 2: source

It is a large oil painting, with dimensions of 194.3 cm × 123.8 cm (76.5 in × 48.7 in). Figure 3 shows the net of a hypercube (or tesseract).


Figure 3: source

What reminded me of my youthful investigation into the realm of the hypercube was a Mathologer video that I watched today titled The Iron Man hyperspace formula really works.


Figure 4 shows a screenshot that demonstrates information about the number of vertices, edges and faces in an \(n\)-dimensional cube where \(n\) varies from 0 to 4. Looking at it, we see that a zero dimensional "cube" consists of only a single point or vertex. The number of vertices is shown by the coefficients of the \(x^0\) terms, coloured red. A one dimensional "cube", corresponding to a line, has two vertices and one edge. The number of edges is shown by the coefficients of the \(x^1\) terms, coloured green. A two dimensional "cube", corresponding to a square, has four vertices, 4 edges and one face. The number of faces is shown by the coefficients of the \(x^2\) terms. The familiar three dimensional cube has 8 vertices, 12 edges and 6 faces, plus one cube. The number of cubes is shown by the coefficients of the \(x^3\) terms. The four dimensional hypercube has 16 vertices, 32 edges, 24 faces, 8 cubes and one hypercube. The vertices, edges, faces and cubes can be counted using the net shown in Figure 2.


Figure 4: source

Figure 5 shows another screenshot where a more general version of Euler's polyhedron formula is displayed. It begins with one dimension where a line of finite length does indeed have two end points or vertices. Thus V=2. For two dimensions, the number of vertices equals the number of edges e.g. consider a square. Thus V=E. For three dimensions, we have the familiar V-E+F=2 and for the hypercube we have V-E+F-C=0 because as can be seen in Figure 4, V=16, E=32, F=24 and C=8.


Figure 5: source

However, getting back to Dali's hypercube, I just finished watching an interesting talk about Dali from an American mathematician who met the artist on a number of occasions. The video is titled Math Encounters -- Encountering Salvador Dali in the Fourth Dimension. 


The video was uploaded in March of 2014 and the mathematician, Tom Banchoff, is still alive and now aged 83. He born on April 7th 1938. He has written a book, titled Beyond the Third Dimension Geometry, Computer Graphics, and Higher Dimensions, a digital copy of which I've managed to acquire. It was first published in 1990. The cover is shown in Figure 6.


Figure 6

The author makes mention of his book in this talk and mentions also Flatland which is a classic that I remember reading many years ago but exactly when I can't recall. Here is a little more about this 1884 book:
This masterpiece of science (and mathematical) fiction is a delightfully unique and highly entertaining satire that has charmed readers for more than 100 years. The work of English clergyman, educator and Shakespearean scholar Edwin A. Abbott (1838-1926), it describes the journeys of A. Square, a mathematician and resident of the two-dimensional Flatland, where women-thin, straight lines-are the lowliest of shapes, and where men may have any number of sides, depending on their social status. 
Through strange occurrences that bring him into contact with a host of geometric forms, Square has adventures in Spaceland (three dimensions), Lineland (one dimension) and Pointland (no dimensions) and ultimately entertains thoughts of visiting a land of four dimensions—a revolutionary idea for which he is returned to his two-dimensional world. Charmingly illustrated by the author, Flatland is not only fascinating reading, it is still a first-rate fictional introduction to the concept of the multiple dimensions of space. "Instructive, entertaining, and stimulating to the imagination." — Mathematics Teacher.
Figure 7 shows the frontispiece to the original publication. Dali was probably familiar with this book as he was very interested in such dimensional adventures. 


Figure 7

Speaking of Flatland's two dimensions, what would a hypercube look like in Flatland? One way it could appear is shown in Figure 8. I got this image from an interesting web page about hypercubes.

Figure 8: source

Figure 9 gives a clearer idea of why this is so. The shadow of the tesseract, itself the 3D shadow of the hypercube, is shown falling on a two dimensional surface.


Figure 9: source

To end this post, I'll return to Mathologer and his YouTube channel. In July of 2017, he posted an interesting video about hypercube shadows that's well worth a look.

Monday, 30 August 2021

The Euler Polynomial

I've made mention of the Euler polynomial \(n^2+n+41\) before in a post titled Prime Producing Linear Polynomials back in August 28th 2018, that contained the snippet shown in Figure 1. This polynomial is quadratic and not linear of course.


Figure 1

I was reminded of this polynomial again today because my diurnal age of 26447 days featured in OEIS A228183:


 A228183

Semiprimes generated by the Euler polynomial \(n^2 + n + 41\).           


The sequence runs:
1681, 1763, 2021, 2491, 3233, 4331, 5893, 6683, 6847, 7181, 7697, 8051, 8413, 9353, 10547, 10961, 12031, 13847, 14803, 15047, 15293, 16043, 16297, 17071, 18673, 19223, 19781, 20633, 21797, 24221, 25481, 26123, 26447, ...

This reminded me that the Euler polynomial is not only an excellent producer of primes, at least initially, but also an excellent generator of semiprimes. Up until \(n=420\), the polynomial produces only primes and semiprimes: 280 primes and 138 semiprimes or 67% and 33%. This ratio is very close to 2/3 and 1/3 and so primes are produced twice as often as semiprimes. In this range, it should be noted that \(n=40\) produces 1681 which is \(41^2\) and thus not technically a semiprime because both factors are the same.

If we extend our range to one million, these percentages alter significantly. We find that there are 261080 primes and 458947 semiprimes and thus primes constitute 26.1% while semiprimes constitute 45.9%. About 28% of the numbers generated clearly have three or more factors and, as mentioned earlier, the run of primes and semiprimes stops with \(n=420) because here we encounter the first sphenic number, that is a number with three distinct prime factors. See Figure 2.


Figure 2

Looking at Figure 2, it can be seen that while the primes and semiprimes still abound, the first two sphenic numbers make their appearance when \(n=420\) and \(n=431\). In fact, up to \( n=1000\), there are only 22 sphenic numbers. See Figure 3.


Figure 3

The first number with four distinct prime factors occurs with \(n=2911\) where the generated number of 8476873 = 41 x 47 x 53 x 83. In the range up to 10,000, there are only 21 such numbers. See Figure 4.


Figure 4

The first number with five distinct prime factors does not occur until \(n=38913\) where the generated number 1514260523 = 43 x 47 x 61 x 71 x 173. In the range up to 100,000, there are only 18 such numbers. See Figure 5.


Figure 5

The first number with six distinct prime factors does not occur until \(n=707864\) generates the number 501072150401 = 41 x 43 x 47 x 53 x 71 x 1607. In the range up to one million, there are only five such numbers. See Figure 6.


Figure 6

Up to one million, there is a total of 6627 numbers containing squares e.g. for \(n=999786\), the number generated is 999573045623 = 47 x 47  x 97 x 4664951. These sorts of numbers constitute only 0.6627% of the total. 

In the range up to 100,000, the breakdown is as follows (permalink):
  • 31984 prime numbers
  • 47937 semiprimes
  • 17741 sphenic numbers
  • 1661 numbers with four distinct prime factors
  • 18 numbers with five distinct prime factors
  • 659 numbers that are not square free.

Figure 7 compares these 100,000 numbers which range from \(43\) to \(100000^2+100000+41\) to the first 100,000 numbers which is perhaps not entirely fair but it does provide some basis for comparison. The striking difference in the proportions of numbers containing squares is clearly evident.


Figure 7

As can be seen in Figure 7, the Euler polynomial does a great job in churning out primes and semiprimes.

Wednesday, 25 August 2021

Random Walks

Suppose an ant starts at the origin or (0,0) in the Cartesian coordinate system and moves one unit at a time upwards or sideways but only to the right. This binary choice is made randomly. Figure 1 illustrates the situation and shows that the ant will end up after three moves at either P, Q, R or S.


Figure 1

Suppose a boundary is imposed beyond with the ant cannot proceed. This boundary is marked by the lines \(x=100\) and \(y=100\). If the ant reaches this boundary, its motion stops. In effect, the ant's path is confined to 100 x 100 grid of squares. The four central squares are (50, 50), (50, 51), (51, 50) and (51, 51). The ant's movement also stops if it reaches any of these central squares. With its current movement constraints, it can only reach the first three of these central squares.

I thought that I'd write a program in SageMath to simulate the ant's journey whose path will terminate either at the boundary or at one of the four central squares. Figure 2 shows a journey at ends at the boundary.


Figure 2: permalink

Figure 3 shows a journey that ends at one of the four central squares.


Figure 3: permalink

It's easy enough to modify the program that different restraints are imposed on the ant's movements. For example, as well as moving upwards or to the right, it could also be allowed to move diagonally upwards. The resulting motion is similar but tends to drive it more toward the line \(y=x\) as shown in Figures 4 and 5 where the path reaches the boundary and the central squares respectively.


Figure 4: permalink



Figure 5: permalink

My simple programming activity was stimulated by watching a YouTube video that simulated lightning strikes and was more complex and written in Mathematica.


It is interesting to explore the probability that the ant will be stopped in the centre of the grid. Over 10,000 trials, I found that when the ant has three possible movements (up, right and diagonally up), the likelihood of being stopped in the centre is a little under 8.5% and never below 8% in my testing. Permalink. When only up and right movement is allowed, the likelihood is definitely lower with percentages ranging a little above and a little below 8%. Permalink.


It's interesting to experiment with different types of movements. An example is a restricted knight move where the ant can move two up and one to the right or one up and two to the right. Figures 6 and 7 show examples of the two possible paths. The likelihood of the ant's journey being stopped in the centre is fairly tightly centred on 8%.


Figure 6: permalink




Figure 7: permalink

There's plenty of scope for further experimentation but I'd best leave off there.

Tuesday, 24 August 2021

Recursion involving the Divisor Function

Interesting results arise when we consider the following iterative process involving a starting number \(n\):$$ \begin{align} n&=\frac{n}{\sigma(n,0)} \text{    if } n \equiv 0  \! \! \! \mod \sigma(n,0)\\ n&=n+\sigma(n,0) \text{    if } n \not \equiv 0 \! \! \! \mod \sigma(n,0) \end{align}$$This has the effect of quickly reducing the size of the number when it is divisible by the number of its divisors and increasing the number slightly in the case where it is not divisible before trying again.

Let's consider what happens to the number 42 under this recursive process:

  • 42 has 8 divisors [1, 2, 3, 6, 7, 14, 21, 42]
    42 isn't divisible by 8, so 42 --> 42 + 8 = 50

  • 50 has 6 divisors [1, 2, 5, 10, 25, 50]
    50 isn't divisible by 6 so 50 --> 50 + 6 = 56

  • 56 has 8 divisors [1, 2, 4, 7, 8, 14, 28, 56]
    8 does divide into 56 to give 7

  • 7 has 2 divisors [1, 7]
    7 isn't divisible by 2 so 7 --> 7 + 2 = 9

  • 9 has 3 divisors [1, 3, 9]
    3 does divide into 9 to give 3

  • 3 has 2 divisors [1, 3]
    3 isn't divisible by 2 so 3 --> 3 + 2 = 5

  • 5 has 2 divisors [1, 5]
    5 isn't divisible by 2 and so 5 --> 5 + 2 = 7
Thus the trajectory of 42 ends in a loop because 5 takes us back to 7. The trajectory is thus 42, 50, 56, 7, 9, 3, 5. All trajectories end in this loop as far as I can determine. In this case, the number of steps is 6 and the trajectory has 7 members when including the starting number.

As usual, it's interesting to look for those numbers that have trajectories of record length. What I found in the range up to 30,000 was the following (SageMathCell permalink):

1, 2, 3, 4, 6, 11, 27, 216, 224, 227, 425, 815, 1641, 13244, 19305, 19317 

These numbers corresponded to trajectories of the following lengths:

1, 2, 4, 5, 8, 16, 75, 77, 78, 105, 275, 282, 951, 952, 1393, 1396

Figure 1 shows these results in tabular format. 


Figure 1

What's surprising is that a relatively small number like 19317 can have a trajectory length of 1396. It's interesting to look at the trajectory of this number. Figure 2 is a plot of the trajectory lengths.


Figure 2

Looking at Figure 2, we see how there is steady buildup until a number (27252) that is divisible by its number of divisors (18) and then there is a precipitous drop to 1514 and the same process is repeated on a smaller scale for what looks like two more times. 

We can see the same process at work a little more clearly for 27 that has a record length of 75. See Figure 3.


Figure 3

Here is the full trajectory of 27 that ends in the 7, 9, 3, 5 loop:
27, 31, 33, 37, 39, 43, 45, 51, 55, 59, 61, 63, 69, 73, 75, 81, 86, 90, 102, 110, 118, 122, 126, 138, 146, 150, 162, 172, 178, 182, 190, 198, 210, 226, 230, 238, 246, 254, 258, 266, 274, 278, 282, 290, 298, 302, 306, 318, 326, 330, 346, 350, 362, 366, 374, 382, 386, 390, 406, 414, 426, 434, 442, 450, 25, 28, 34, 38, 42, 50, 56, 7, 9, 3, 5

Monday, 23 August 2021

Polydivisible or Magic Numbers

Today I turned 26440 days old and discovered a new type of number, one termed polydivisible or magic. Here is a definition from Wikipedia:

In mathematics a polydivisible number (or magic number) is a number in a given number base with digits \(abcde \dots \) that has the following properties:

  • Its first digit \(a\) is not 0.
  • The number formed by its first two digits \(ab\) is a multiple of 2.
  • The number formed by its first three digits \(abc\) is a multiple of 3.
  • The number formed by its first four digits \(abcd\) is a multiple of 4.
  • etc.
To put it in formal mathematical terms, we have:

Let \(n\) be a natural number, and let \(k = \lfloor \log_{b}{n} \rfloor + 1\) be the number of digits in \(n\) written in base \(b\). The number \(n\) is a polydivisible number if for all \(0 \leq i < k\):$$\frac{n - (n \bmod b^{k - i - 1})}{b^{k - i - 1}} \equiv 0 \pmod i$$Using the initiall less formal, definition it can be seen that 26440 qualifies because:
  • the first digit 2 is not 0
  • the number formed by its first two digits 26 is a multiple of 2
  • the number formed by its first three digits 264 is a multiple of 3
  • the number formed by its first four digits 2644 is a multiple of 4
  • the number formed by its first five digits 26440 is a multiple of 5
The polydivisible numbers in base 10 form OEIS A144688 and though defined differently, it amounts to the same thing:


 A144688

"Magic" numbers: all numbers from 0 to 9 are magic; a number >= 10 is magic if it is divisible by the number of its digits and the number obtained by deleting the final digit is also magic.


The OEIS comments tell us that there are exactly 20457 terms, the largest of which is the 25-digit number 3608528850368400786036725. For any given base \(b\), there are only a finite number of polydivisible numbers. After 26440, the next polydivisible number is 26445 followed by 26480, 26485 and then a relatively large gap to 26720. In the range up to 26440, about 2.7% of numbers are polydivisible.

Figure 1 shows the distribution of the number of polydivisible numbers with \(n\) digits. These numbers form OEIS A143671.


Figure 1: permalink

From Wikipedia we learn that:
Polydivisible numbers represent a generalisation of the following well-known problem in recreational mathematics:

Arrange the digits 1 to 9 in order so that the first two digits form a multiple of 2, the first three digits form a multiple of 3, the first four digits form a multiple of 4 etc. and finally the entire number is a multiple of 9.

The solution to the problem is a nine-digit polydivisible number with the additional condition that it contains the digits 1 to 9 exactly once each. There are 2,492 nine-digit polydivisible numbers, but the only one that satisfies the additional condition is:

381 654 729
Numberphile made a video about this polydivisible number.


Wikipedia also list the following problems associated with polydivisible numbers:
  • Finding polydivisible numbers with additional restrictions on the digits - for example, the longest polydivisible number that only uses even digits is 48000688208466084040.

  • Finding palindromic polydivisible numbers e.g. the longest palindromic polydivisible number is 30000600003.

  • A common, trivial extension of the aforementioned example is to arrange the digits 0 to 9 to make a 10 digit number in the same way, the result is 3816547290. This is a pandigital polydivisible number that includes 0.