Building in Desmos

To begin building the polygonal number diagrams in Desmos[2], begin with creating sliders for nn and kk, and a sequence NN of the integers between 11 and nn. The base angle can also be defined.

Slider nn; 1n1001\leq n\leq 100 step: 1

Slider kk; 2k1002\leq k\leq 100 step: 1

N=[1,,n]N=\left[1,\ ...\ ,n\ \right]

angle=π(k2)πka_{ngle}=\pi-(k-2)\cdot\frac{\pi}{k}

Chose a variable name that does not correspond to one of the already used variables, and implement equations (4) and (5). The value of kk is defined globally and does not need to be passed as a paramenter. The value of nn is not used directly; instead, the functions will be evaluated using the values of the array NN. Here ll will be used as the parameter name rather than nn.

g(l)=(k4)+sqrt((k4)2+8l(k2))/(2(k2))g(l)=(k-4)+\text{sqrt}((k-4)^{2}+8l(k-2))/(2(k-2))
gnomon(l)=floor(g(l))g_{nomon}(l)=\text{floor}(g(l))

Next, implement the gnomon size and depth functions.

gsize(l)=1+(gnomon(l)1)(k2)g_{size}(l)=1+(g_{nomon}(l)-1)\cdot(k-2)
gdepth(l)=i=1l(floor(gnomon(i)/gnomon(l)))g_{depth}(l)=\sum_{i=1}^{l}(\text{floor}(g_{nomon}(i)/g_{nomon}(l)))

Finally, the equations for the coordinates of each plotted point can be defined based on equations (9) and (10).

x0(l)=gnomon(l)cos(angle)x_{0}(l)=-g_{nomon}(l)\cos{(a_{ngle})}

y0(l))=gnomon(l)sin(angle)y_{0}(l))=g_{nomon}(l)\sin{(a_{ngle})}
xpoly(l)=x0(l)j=1gdepth(l)1cos(angle(ceil((j/gsize(l))(k2))+1))x_{poly}(l)=x_{0}(l)-\sum_{j=1}^{g_{depth}(l)-1}\cos(a_{ngle}\cdot(%
\operatorname{ceil}(({j}/{g_{size}(l)})(k-2))+1))



ypoly(l)=y0(l)j=1gdepth(l)1sin(angle(ceil((j/gsize(l))(k2))+1))y_{poly}(l)=y_{0}(l)-\sum_{j=1}^{g_{depth}(l)-1}\sin(a_{ngle}\cdot(%
\operatorname{ceil}(({j}/{g_{size}(l)})(k-2))+1))

To plot the points, the functions above are applied to the sequence NN. The grid and axis can be removed from the plot.

(xpoly(N),ypoly(N))(x_{poly}(N),y_{poly}(N))

A completed implementation of these instructions can be found here:

https://www.desmos.com/calculator/cz80t85moz.