Grid Visualizer

This visualizer puts a sequence in a square spiral or in rows and allows you to highlight its values based on various properties.

The inspiration for this visualizer is Ulam's spiral, which puts the natural numbers in a square spiral and highlights the primes. One can also highlight properties such a whether a number is abundant or polygonal. Several properties can be highlighted at once, in which case later properties overcolor earlier ones.

Parameters

Presets: Which preset to display

If a preset other than Custom is selected, then the Properties portion of the dialog is overriden. For details on the meanings of the terms below, see the Properties section of the documentation.

  • Custom: the remaining properties can be set by you
  • Primes: primes are shown in red
  • Abundant_Numbers: the abundant numbers are shown in black
  • Abundant_Numbers_And_Primes: the primes are shown in red and the abundant numbers in black
  • Polygonal_Numbers: the polygonal numbers are shown in a variety of different colors (one for each type of polygon)
  • Color_By_Last_Digit_1: the last digit is shown (one color for each digit in a rainbow style)
  • Color_By_Last_Digit_2: a variation on the last, where odd digits are indicated by smaller boxes

Grid cells: The number of cells to display in the grid

This will be rounded down to the nearest square integer. This may get laggy when it is in the thousands or higher, depending on the property being tested.

Starting Index: The sequence index at which to begin

Path in grid: The path to follow while filling numbers into the grid.

  • Spiral: An Ulam-type square spiral starting at the center of grid.
  • Rows: Left-to-right, top-to-bottom in rows.
  • Rows_Augment: Each row restarts the sequence from the starting index, but adds the row number to the sequence values.

Show numbers: Whether to show values overlaid on cells

When this is selected, the number of cells in the grid will be limited to 400 even if you choose more.

Number color: The font color of displayed numbers

This parameter is only available when the "Show Numbers" parameter is checked.

Background Color: Background color of the grid

Property 1, 2, etc.: Properties to display by coloring cells

You can add multiple properties. For each, there are some parameters to set.

Property: the property to highlight

The description for each property specifies the conditions under which that property holds for a given integer.

  • None: This is simply a placeholder to indicate that no further properties will be used. Choosing anything other than none will add a new property and reveal parameters for it.
  • Prime: Its absolute value is prime
  • Negative: Less than zero
  • Even: Divisible by two
  • Odd: Not even
  • Divisible_By: Divisible by the specified divisor
  • Last_Digit_Is: The final digit base 10 is the specified digit
  • Polygonal_Number: Positive and that many dots can be arranged in a polygonal arrangement with the specified number of sides.
  • Sum_Of_Two_Squares: Nonnegative and equal to the sum of two squares
  • Abundant: Its absolute value exceeds the sum of its proper divisors
  • Perfect: Equal to the sum of its proper divisors
  • Deficient: Its absolute value is less than the sum of its proper divisors
  • Semi_Prime: Its absolute value is a semi-prime, that is, a product of exactly two primes (possibly equal)
Display: Highlight style for cells with the property

Using different display styles allows for visualizing two properties that are both true for the same value at once, without them overcoloring each other. (Note that later properties overcolor earlier ones that use the same style.)

  • Fill_Cell: Fill the complete cell
  • Box_In_Cell: Fill only a smaller central box in the cell
Color: Highlight color for cells with the property

Examples

Click on any image to expand it.

The Ulam Spiral

These are the natural numbers in a square spiral, with each of the prime numbers highlighted in red; this is the classic Ulam spiral. In the first image, the value of each term of the sequence is shown over the corresponding cell, in order to demonstrate the spiral. In the second, we see many more terms, whereupon it becomes evident that the primes form long diagonal lines. These diagonal lines are quadratic equations, namely , , , and .

Traversing the grid in rows

The natural numbers are put in rows (left to right, top to bottom), with each of the prime numbers highlighted in red. Primes can only appear at positions which are coprime to the rowlength, leading to the visual effect of black columns.

The Rows_Augment capability

When you choose Rows_Augment for the parameter Path in Grid, the sequence starts over in each row, but its values are incremented by one. In this example, primes are again highlighted in red. (1) and (2): natural numbers; (3) and (4): squares. In the second series of images, long diagonal lines become apparent. The diagonal lines that go up and to the right each have a corresponding diagonal line that goes down and to the right because numbers repeat when they are arranged this way. The quadratic equation for which each of these diagonals corresponds is .

Abundant numbers (A005101) and primes

Abundant numbers (A005101) are those less than their sum of proper divisors. The first two images show a spiral and row arrangement of the natural numbers, with abundant numbers in black on a white background.

The last image combines abundant and primes in a spiral arrangement of the natural numbers. The primes appear to fit "around" the abundant numbers (this effect is easiest to appreciate by clicking on the last image to expand it). This is a tendency, not a rule, as most (but not all) abundant numbers are divisible by 2 or 3.

Polygonal Numbers

Putting the natural numbers in a spiral or in rows (first two images), we can highlight the polygonal numbers. Polygonal numbers count dots that can be arranged in the shape of that polygon. For example, 6 is a triangular number because one can form an equilateral triangle with three dots at the bottom, two dots in the middle, and one dot at the top. The triangular numbers are red, square numbers are orange, pentagonal yellow, hexagonal green, heptagonal blue, and the octagonal numbers are purple. For the final image, we use the sequence of squares, and use the Rows_Augment mode.

Digit colorings

The first image shows the natural numbers in rows, colored by final digit. The second image is the same, but in spiral format. The final image shows the digits of pi (A000796) in rows.

Digits of abundant numbers (A005101)

When the abundant numbers are put in a spiral and highlighted by their last digit, the scarcity of odd abundant numbers (indicated on the left by small squares) becomes visually apparent. As we zoom out in the right image, we see they are clearly not random.

Credit

The original version of this visualizer was created by James Brobin, as part of the Experimental Mathematics Lab at CU Boulder.