HomeSoftware Basic
logo

Programming

Basic

Warthog-spectrum

Let F be a natural number. Consider the values N=1,2,3,4,....,F. We will draw a figure formed by F segments of equal length, such that the starting point of each segment is the end point of the previous one, and the bearing of each segment is defined by the fractional value of the function N^3/F. Example: F=3 N=1,2,3 ZZ(N)=(N^3)/3 ZZ(1)=1/3 ZZ(2)=2/3 ZZ(3)=3/3=1 The corresponding bearings (from 0º to 360º) will be Z(1)=120º Z(2)=240º Z(3)=360º and the resulting figure is an equilateral triangle. But we can continue experimenting for F=3,4,5,6,7,8,9,10,... each time we obtain a different figure!

Warthog-Spectrum
Figure 1. Basic code for Warthog on the ZX Spectrum 48K microcomputer. The program asks at line 20 for different values of F, each of which produces a different figure. When F is large, the execution time can be hours... (using the ZX Spectrum 48K), but it was worth the wait to see the result:
w-003
w-003
w-004
w-004
w-005
w-005
w-006
w-006
w-007
w-007
w-008
w-008
w-009
w-009
w-010
w-010
w-088
w-088
w-098
w-098
w-099
w-099
w-1050
w-1050
w-126
w-126
w-136
w-136
w-147
w-147
w-149
w-149

These figures have been generated with the Warthog for Octave version of the algorithm, but the same result is achieved with the ZX Spectrum. The first third of the segments are coloured red, the second third green, and the last third red, giving a more attractive visual appearance. It is interesting to note how the evolution of the shape of the figures is not progressive. Generally, figure F+1 is not a small variation of figure F. Although each value of F gives a different figure, certain surprising patterns repeat in shape. Some figures laugh at us. The question is, how is it possible that all these figures are hidden inside the function (N^3)/F?