Pages

28 July 2025

The magic square of 1/19

Introduction


For 1/19 as generator of the 18x18 magic square


 see here. The 18 rows, 18 columns and 2 diagonals all add up to 81. Each row and each column contains one 0 and one 9, and each other digit twice. In this post we implement this magic square, coloured, in GeoGebra.


The colour code for the digits can be deduced from the first column, whose successive colours represent 0,1,2,3,4,5,6,7,8,9, Each row and each column contains one red and one black square, and each other colour twice.

The digits


The digits of 1/19 can be obtained from the On-line Encyclopedia of Integer Sequences (here). The first 18 digits of 1/19 are endlessly repeated, and its multiples 2/19,...,18/19 have the same period. The lists below give the first periods of 1/19 up to 18/19. They can be obtained (though not in order) by rotating the digits in the first list.
  • digits01 = {0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1}
  • digits02 = {1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2}
  • digits03 = {1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3}
  • digits04 = {2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4}
  • digits05 = {2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5}
  • digits06 = {3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6}
  • digits07 = {3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7}
  • digits08 = {4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8}
  • digits09 = {4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9}
  • digits10 = {5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0}
  • digits11 = {5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1}
  • digits12 = {6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2}
  • digits13 = {6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3}
  • digits14 = {7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4}
  • digits15 = {7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5}
  • digits16 = {8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6}
  • digits17 = {8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7}
  • digits18 = {9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8}

The list of all 324 digits {0, 5, 2, ..., 5, 7, 8}, from the first in digits01 to the last in digits18, is obtained in digits below.

  • digits00={digits01, digits02, digits03, digits04, digits05, digits06, digits07, digits08,d igits09,d igits10, digits11, digits12, digits13, digits14, digits15, digits16, digits17, digits18}
  • digits=flatten(digits00)

The squares


coor is the list of coordinates (1,18), (2,18), ..., (18,18), (1,17), ..., (18,1), i.e., row after row, from top to bottom.

  • to18=Sequence(18)
  • h01=(to18, 1) etc h18=(to18, 18)
  • coor00={h18, h17, h16, h15, h14, h13, h12, h11, h10, h09, h08, h07, h06, h05, h04, h03, h02, h01}
  • coor=flatten(coor00)

squares is the list of the 324 unit squares centered at the coordinates in coor.

  • coorlu=coor + (-0.5, -0.5)
  • coorru=coor + (0.5, -0.5)
  • squares=Sequence(Polygon(coorlu(k), coorru(k), 4), k, 1, 18 * 18)


squares and coor

Squares coloured per digit


The list is0 is {1, 20, 50, ..., 316}, consisting of the numbers k among {1, 2, 3, ..., 324} such that digits(k) is 0, and squares0 consists of the squares containing a 0. 

  • is0=KeepIf(digits(k) ≟ 0, k, 18*18) 
  • squares0=Sequence(squares(is0(k)), k, 1, Length(is0))

Doing the same for 1,2,...,9 one obtains the ten-colour square shown above. To separate the squares, a black grid has been added:

  • hori=Sequence(Segment((0.5, k - 0.5), (18.5, k - 0.5)), k, 1, 19)
  • verti=Sequence(Segment((k - 0.5, 0.5), (k - 0.5, 18.5)), k, 1, 19)






26 July 2025

Ulam's Spiral in GeoGebra

Ulam's Spiral is a square spiral of natural numbers, on which the prime numbers are highlighted. (See here.) In this post we implement it in GeoGebra 5 (manual here). 

A. The grid


GeoGebra commands.
  1. d=15
  2. verti=Sequence(Segment((k, -d), (k, d)), k, -d, d)
  3. hori=Sequence(Segment((-d, k), (d, k)), k, -d, d)
Comment. 
  1. d is the dimension of the grid, which will extend from (-d,-d) lower left to (d,d) upper right. 
  2. verti is the list of vertical segments in the grid.
  3. hori contains the horizontal segments.





 B. The square spiral


Introduction.

To generate the counterclockwise square spiral, the steps (Right, Up, Left, Down) starting from the origin (0,0) are: 

R U LL DD RRR UUU LLLL DDDD ...     (*)

The last complete cycle right-up-left-down is

R(2d-1 times) U(2d-1 times) L(2d times) D(2d times)

and it ends in (-d,-d). The effects of (*) on the abscissas are

+1 0 -1 -1 0 0 +1 +1 +1 0 0 0 -1 -1 -1 -1 0 0 0 0 ...     (a)

and on the ordinates

0 +1 0 0 -1 -1 0 0 0 +1 +1 +1 0 0 0 0 -1 -1 -1 -1 ...     (o) 

These sequences are obtained as xsteps and ysteps below. To end in (-d,d) there are 2d more steps right required. 

GeoGebra commands.

  1. plus=Sequence(Sequence(1, m, 1, k), k, 1, 2d)
  2. minus=Sequence(Sequence(-1, m, 1, k), k, 1, 2d)
  3. zero=Sequence(Sequence(0, m, 1, k), k, 1, 2d)
  4. odds=Sequence(k, k, 1, 2d - 1, 2)
  5. xstepsb=Zip({plus(A), zero(A), minus(A + 1), zero(A + 1)}, A, odds)
  6. xsteps=Flatten(xstepsb)
  7. xstepsclose=Sequence(1, i, 1, 2d)
  8. xstepsclosed=Join({xsteps, xstepsclose})
  9. xs=Sequence(Sum(xstepsclosed(m), m, 1, k), k, 1, Length(xstepsclosed))
  10. ystepsb=Zip({zero(A), plus(A), zero(A + 1), minus(A + 1)}, A, odds)
  11. ysteps=Flatten(ystepsb)
  12. ystepsclose=Sequence(0, i, 1, 2d)
  13. ystepsclosed=Join({ysteps, ystepsclose})
  14. ys=Sequence(Sum(ystepsclosed(m), m, 1, k), k, 1, Length(ystepsclosed))
  15. xsys=Sequence((xs(k), ys(k)), k, 1, Length(xstepsclosed))
  16. points=Append((0, 0), xsys)
  17. spiral=Polyline(points)
Comment.
  1. plus is the sequence {{1},{1,1},{1,1,1},...} with the last term containing 2d numbers.
  2. minus is {{-1},{-1,-1},{-1,-1,-1},...}. 
  3. zero is {{0},{0,0},{0,0,0},...}. 
  4. odds is the sequence {1,3,5,...,2d-1}, used in the two ZIP operations, in which the step is 2. 
  5. xstepsb is the sequence {{{1}, {0}, {-1, -1}, {0, 0}}, {{1, 1, 1}, {0, 0, 0}, {-1, -1, -1, -1}, {0, 0, 0, 0}}, ...}, consisting of two sets of 1 term, then two of 2 terms, three of 3 terms etc.
  6. xsteps is the sequence (a) mentioned above.
  7. xstepsclose is a constant sequence of 2d numbers 1.
  8. xstepsclosed contains the steps in the abscissa up to the last point (-d,d).
  9. xs is {1, 1, 0, -1, -1, -1, ..., d}, the successive partial sums of the previous list, hence the successive abscissas of the points on the spiral.
  10. is 5. for ordinates.
  11. is 6. for ordinates, resulting in the sequence (o) mentioned above.
  12. is 7. for ordinates.
  13. is 8. for ordinates.
  14. is 9. for ordinates.
  15. xsys is the list of successive coordinates of all points on the spiral except the origin.
  16. points is {(0,0),(1,0),(1,1),...(d,-d)}, the list of all points on the spiral. 
  17. spiral is the square spiral starting in (0,0) and ending in (d,-d).


C. Ulam's spiral 


 GeoGebra commands.
  1. gridnumber=(2d + 1)²
  2. lastprime=PreviousPrime(gridnumber)
  3. gridprime=KeepIf(IsPrime(a), a, Sequence(gridnumber))
  4. ulam=Sequence(points(gridprime(k)), k, 1, Length(gridprime))
Comment.
  1. gridnumber is the number of points in the grid, i.e., on the spiral.
  2. lastprime is the greatest prime number in the sequence {1,2,...,(2d + 1)²}.
  3. gridprime contains the prime numbers in {1,2,...,(2d + 1)²}.
  4. ulam is {(1,0),(1,1),(-1,1),(-1,-1),(2,0),...}, the sequence of the points on the spiral  whose sequence number is prime.


 


18 July 2025

Artistieke wiskunde, opus XIII --- de driehoek van Morley

 


De hoeken van de driehoek zijn in drie gelijke delen verdeeld. Dit is onmogelijk met passer en liniaal (stelling van Wantzel), maar wordt door GeoGebra voortreffelijk uitgevoerd. Als men telkens de "onderste" twee trisectrices met elkaar snijdt ontstaat een gelijkzijdige driehoek, in het zwart uitgevoerd. Een elementair bewijs van deze stelling van Morley vindt men hier.

Deze configuratie bevat nog veel meer merkwaardigs dan alleen de driehoek van Morley.

Concurrente rechten:



en zestallen op een ellips:



(M.b.v. de raaklijnen uit de hoekpunten aan de vorige ellips, in het blauw)


Deze eigenschappen kaderen in de context van de stelling van Carnot over de snijpunten van een ellips met de zijden van een driehoek. De meeste vernoemde eigenschappen vindt men, met bewijzen, in Lorenz Halbeisen, Norbert Hungerbühler, Juan Läuchli: Mit harmonischen Verhältnissen zu Kegelschnitten: Perlen der klassischen Geometrie. Springer 2016.