Showing posts with label diagonal. Show all posts
Showing posts with label diagonal. Show all posts

Friday, 30 May 2025

Random Walks

On the 20th of December 2018, I uploaded a post titled Random Walks in which I looked at random walks within a grids of fixed size. For example, consider a 4 x 4 grid of points where the walk starts at (0, 0) and finishes at (4, 4). Movement can be vertical (up or down) or horizontal (left or right) but is confined to the grid. Diagonal movement in one step is not possible. See Figure 1.


Figure 1

I created a program (permalink) to simulate 1000 random walks and calculate the median of the number of steps required to travel from (0, 0) to (4, 4). It turned out to be about 60 steps. In this post, I looked at other 2-D grid sizes and also random walks in 3 dimensions with varying grid sizes (permalink). See Figure 2.


Figure 2

This present post was inspired by a Cliff Pickover tweet. See Figure 3.


Figure 3

I created a SageMath program (permalink) to simulate a 2-D random walk starting at the origin and concluding at the origin (if it is ever reached). Movement can be up or down one step and\or left or right one step, so diagonal movement is possible. See Figure 4.

Figure 4

I set a step limit of 100,000 and quite often the walk had not returned to the origin by then. See Figure 5.


Figure 5

At other times, it would return to the origin within the limit imposed. See Figure 6 and Figure 7.


Figure 6


Figure 7

Often the walk will end after a few dozen steps or less and these shorter walks are by far the most common. See Figure 8.


Figure 8

This was just an introductory look at 2-D random walks upon an infinite grid and there's much more to explore. As an example, Figure 9 shows another tweet from Cliff Pickover regarding SAW (Self Avoiding Walks).


Figure 9

Thursday, 25 April 2024

Anti-Magic Squares Revisited

I've written about magic squares before. Here are links to these posts:

In this post, I intend to revisit anti-magic squares and the numbers associated with OEIS A117560:


 A117560

\( \text{a}(n) = \dfrac {n \cdot (n^2-1)}{2} - 1 \)



The OEIS comments state that:
\( \text{a}(n-1) \) is an approximation for the lower bound of the "antimagic constant" of an antimagic square of order \(n\). The antimagic constant here is defined as the least integer in the set of consecutive integers to which the rows, columns and diagonals of the square sum. 
The initial members of this sequence are:

2, 11, 29, 59, 104, 167, 251, 359, 494, 659, 857, 1091, 1364, 1679, 2039, 2447, 2906, 3419, 3989, 4619, 5312, 6071, 6899, 7799, 8774, 9827, 10961, 12179, 13484, 14879, 16367, 17951, 19634, 21419, 23309, 25307, 27416, 29639, 31979, 34439, 37022

27416 is highlighted because it is my diurnal age today and when I made my post about anti-magic squares on July 17th 2018, I was 25307 days old. This number immediately precedes 27416, a gap of 2109 (about 5.77 years in terms of days counted). It will be 2223 days, about 6.09 years, before the next number is reached.

The current number, 27416, relates to an approximation of the lowest integer of a 38 x 38 anti-magic square. Note that it is not necessarily the lowest, it's just an approximation. My July 2018 entry is quite thorough and there's no point repeating all the content there but Figure 1 shows an example of 4 x 4 anti-magic square just to reinforce the property of such a square.

Figure 1: source

The ten sums from a sequence of consecutive numbers, namely 
30, 31, 32, 33, 34, 35, 36, 37, 38, 39. Figure 2 shows a different arrangement. Note that OEIS A117560 gives 29 as the lower bound here.

Figure 2: source

Note that an anti-magic square differs from a so-called heterosquare. As explained in Wolfram Mathworld
A heterosquare is an \(n \times n\) array of the integers from \(1\) to \(n^2\) such that the rows, columns, and diagonals have different sums. By contrast, in a magic square, they have the same sum. There are no heterosquares of order two, but heterosquares of every odd order exist. They can be constructed by placing consecutive integers in a spiral pattern (Fults 1974, Madachy 1979). An antimagic square is a special case of a heterosquare for which the sums of rows, columns, and main diagonals form a sequence of consecutive integers.

Figure 3 shows an example of a 4 x 4 heterosquare:

Figure 3: source

These numbers do not form a sequence of consecutive integers and so they do not form an anti-magic square.

Saturday, 6 July 2019

Visualisation of Semiprimes

I've written previously about semiprimes in varying contexts. These posts are listed below:
I was prompted to make yet another post about them because today I turned 25661 days old and was little of interest to found about this number in either the OEIS, Numbers Aplenty or any other sources. However, it is a semiprime, being a product of 67 and 383. I thought I'd examine the number is a more detailed, two dimensional way. Figure 1 illustrates my approach.

Figure 1

I've revisited some old territory in the notes contained in Figure 1 which I've reproduced below:
The number 25661 is a semiprime because it has prime factors of 67 and 383. It can be visualised in two dimensions as a rectangle with a width of 67 units and length of 383 units. As such, its area of course is 25661 square units and its perimeter is 900 units. The ratio of the rectangle's width to its length is thus 67 383 or approximately 0.17493 and the ratio of length to width is 383: 67 or approximately 5.7164. The length of the diagonal of this rectangle is approximately equal to 388.8. The area of the rectangle is equivalent to the sum of the areas of 62 different combinations of three squares. An example is shown where the three squares has sides of 86 units, 92 units and 99 units.
By "old territory", I mean the semiprime is envisioned as a rectangle whose width and length are the smaller and larger prime factors whose product is the area of the rectangle. Thus the integers 900 and 25661 are related via a gematria-like connection. The ratio of the sides produce two other related numbers, both rational, and this case:$$ \frac{67}{383} \approx 0.17493 \text{ and its reciprocal } \frac{383}{67} \approx 5.7164$$What's new is that I've considered the length of the rectangle's diagonal which is an irrational number and equal to \( \sqrt {67^2+383^2} = \sqrt {151178} \approx 388.8162 \).

Finally, I've used the fact that 25661 can be expressed a sum of three squares in 62 different ways to represent the rectangle as being equivalent in area to the sum of any of these three squares. In Figure 1, I've used the example of:$$86^2+92^2+99^2=67 \times 383 =25661$$The square numbers correspond to \( 86^2, 92^2 \text{ and } 99^2 \text{ are } 7396, 8464 \text{ and } 9801 \text{ respectively }\). There are another 61 sets of such triplets that can be linked visually with the rectangular representation of 25661. See Figure 2:

Figure 2