Desmos Polygonal Number Diagrams
Abstract
Polygonal numbers, like the triangular, square, and pentagonal numbers, are closely identified with (or even defined in terms of) the diagrams that they are associated with. The functional programming capabilities of the Desmos graphing calculator provides fun and interesting ways of exploring number diagrams like those associated with polygonal numbers. This short article provides one approach that can be used to build polygonal number diagrams in Desmos.
Polygonal numbers
For a given , the -polygonal numbers[1] are a recursively defined integer sequence, as shown in Equation (1).
(1) |
For a term in the sequence , dots can be arranged in a regular -polygon built up of layers (traditionally referred to as gnomons), as shown for the pentagonal numbers () of Figure (1).

If is the th -polygonal number, it can be drawn as a layered regular -polygon with gnomon layers, as shown for the third pentagonal number , , in Figure (2).

Placing any in a -polygonal diagram
Let , . We would like to draw the polygonal number diagram “up to” . If happens to actually be a polygonal number, this will be a complete diagram with dots in a layered -polygon. Otherwise, this will be a diagram whose outer gnomon layer is incomplete.
Figure (3) shows hexagonal number () diagrams for the numbers 15 and 26. Because 15 actually is a hexagonal number, the diagram is complete. The diagram for 26 shows an incomplete diagram, with an incomplete outer layer.

Finding the gnomon for and
The recursive definition for in Equation (1 yields formulas stated as a summation (2) and a direct calculation (3).
Applying the quadratic formula to solve provides us with
This allows us to identify the gnomon layer that a given will sit in within a -polygonal diagram (5).
The position of within its gnomon layer
The size of the gnomon layer that will sit in (how many dots would be in the layer within the diagram) is given by Equation (6).
To find the position of the th dot within the gnomon, we need to count the number of dots that came before it within that gnomon. To do this we can sum up to over a function whose value is for all where , and whose value is for those where . This sum that gives us the ”depth” of n within its gnomon is provided by Equation (7).
Drawing the diagram
For a given , , the preceding sections tell us which gnomon will be placed in in a -polygonal diagram, and in which spot along the gnomon.
To complete the diagram, we need to also determine how much the gnomon is bent at the particular position that finds itself at. Because the gnomon is a layer in a regular -gon, it bends in increments of the base angle that is given by Equation (8).
As we draw a gnomon, we’ll start at the left-most position, which for a given can be expressed by as defined in (9).
(9) |
Starting at the initial point for a given , we want to move along the gnomon layer up to the gnomon depth of (), bending along the gnomon as required. This process is expressed by the sums in the definitions of and of (10).
(10) |
Building in Desmos
To begin building the polygonal number diagrams in Desmos[2], begin with creating sliders for and , and a sequence of the integers between and . The base angle can also be defined.
Slider ; step: 1
Slider ; step: 1
Chose a variable name that does not correspond to one of the already used variables, and implement equations (4) and (5). The value of is defined globally and does not need to be passed as a paramenter. The value of is not used directly; instead, the functions will be evaluated using the values of the array . Here will be used as the parameter name rather than .
Next, implement the gnomon size and depth functions.
Finally, the equations for the coordinates of each plotted point can be defined based on equations (9) and (10).
To plot the points, the functions above are applied to the sequence . The grid and axis can be removed from the plot.
A completed implementation of these instructions can be found here:
https://www.desmos.com/calculator/cz80t85moz.
Bibliography
- [1] (1998) The book of numbers. Springer Science & Business Media. Cited by: Polygonal numbers.
- [2] Desmos Graphing Calculator software. Note: https://www.desmos.com/ Cited by: Building in Desmos.