Friday, May 22, 2009

Quadratic Number Spirals and Polygonal Numbers

Take the positive Integer number-line, place it in the xy plane (with zero at the origin), and wrap it counterclockwise around the origin so that the formerly straight number-line forms a spiral. Do this so that the square numbers (1, 4, 9, ...) all line up along the positive x axis one unit apart.

Equipped with this number spiral, you can now plot sequences of positive integers on it and, in some cases, interesting curves will emerge. NumberSpiral.com provides a nice overview of why some of these curves form the way they do.

Because of how we have wound our  number spiral, quadratic sequences are particularly nice to plot. So how can we possibly resist spiral-plotting the 2-dimensional polygonal numbers? The plots below are of the 2-dimensional k-polygonal numbers for = 3, 5, 12, and 13, that fall between 1 and 5000.
Plotting two polygonal number sequences on the same spiral gives us a way to see some of the numbers for which the sequences overlap (they do this at what are called highly polygonal numbers). For example, it turns out that every hexagonal number is also a triangular number. The image below shows an overlay of both the k = 6 and k = 3 sequences - numbers that are both hexagonal and triangular are shown as large dots, while the non-hexagonal triangular numbers are smaller.


The square and triangular number sequences line up less exactly than the hexagonal and triangular example above, but their overlap represents a well-known sequence in its own right (Sloane A001110 - see also wikipedia). The square-triangular sequence comes up surprisingly often in recreational mathematics, including a recently in an article about inquisitive computing by Brain Hayes. In the image below, the square numbers are squares, the triangular numbers are dots, and those that are both show up as triangles (1, 36, and  1225 are shown).

The Fathom file used to create these spirals is available here.

Thursday, May 14, 2009

More Phyllotaxis

The images above are updated versions of the phyllotaxis spirals described here and here. These new images are from a Fathom 2.11 file (the file is here) - the new version allows the dots to be re-sized based on formulas within the graphs and input from sliders.

Increasing the pointSize creates a crowding effect that looks like the bottom of a pine cone (see actual pictures here).

You can also generate other interesting spiral forms by varying the parameters as described in the earlier posts.

Tuesday, May 12, 2009

Pascal's Triangle and Polygonal opsgf’s

The diagram above illustrates a surprising correspondence – if you take the reciprocal of a particular polynomial whose coefficients match the d+1 row of Pascal’s Triangle, you obtain a formal power series whose coefficients are precisely the elements in the dth column of the triangle.

The case for the third row is shown above (row and column numbering starts at 0 in Pascal's Triangle), and the case for the fourth row is shown in the diagram below. To actually work out the power series that comes from the reciprocals (well, at least the first few coefficients), the grid method of dividing polynomials works well (I think).


In this way, the rows of the triangle  provide all the information required to obtain the columns - a nice correspondence between a finite sequence and an infinite one.  

You'll see this correspondence if you spend time investigating the "ordinary power series generating functions" (opsgf's) for the higher dimensional triangular numbers. The row polynomials are just (1-x)^(d+1), while the columns correspond to formal power series whose coefficients are the d-dimensional triangular numbers (see this post). A great place to learn about these opsgf's is H. Wilf's book generatingfunctionology, which can be downloaded here.
 
You can uncover the general opsgf for higher dimensional triangular numbers by starting with the (1-x)^(-1) rational function, and applying Wilf's 'rule 5' from chapter 2 of generatingfunctionology

Applying a few other rules, you can obtain an opsgf for the k-polygonal numbers (= 4 is squares, = 5 is pentagonals, = 6 hexagonals, etc.).


Friday, May 1, 2009

Generating Random Walks

"The zest of a walk is its spontaneity."
H. T. Tuckerman from The Optimist, 1850, page 144.

With connections to the study of gambling, Brownian motion, fractals, and more, random walks are a favorite topic in recreational mathematics. See for example the chapters in Martin Gardner's Mathematical Circus, or the entry in Wikipedia.

The diagram above (from Energy transformations during horizontal walking by F. G. Benedict and H. Murschhauser, published in 1915) suggests one method for generating walking data. Creating random walk simulations in Fathom or TinkerPlots is a little more straightforward. 

First simulation - using sliders to determine a 'base angle'

This first example lets you set up random walks where the direction chosen is based on an angle k*2pi/n for a fixed n (whose value is determined by a slider) and a random k (a random integer between 1 and n).

First, create a slider n, then create the attributes below and finally add the data (any number is fine - start with ~500 cases). The formulas below were entered in TinkerPlots, but would work equally well in Fathom.

Plots of (x,y) will show the walk, and plots of (step, distance) will show how the distance from the origin changes over the course of the walk. Different values for n provide walks with their own particular geometries.

The walks start at (0,0) and wander about the plane from there. Re-randomizing (CNTRL-Y) generates new walks.

The simulation gives lots of nice pictures of random walks. You could generate statistics from these by adding measures and measure collections.

One limitation of this simulation is that it is difficult to determine exactly when the walker has returned to the start (0,0).  This turns out to be an interesting question for random walks on the plane (see the wikipedia entry for more on this). Because of the inexactness in the positions calculated using sine and cosine, the walker seems to never return to the origin. There are several ways of dealing with this, but one is to design a simpler simulation that uses exact values - one that sticks to lattice points (xy), where x and y are both integers.  

Second simulation - sticking to Integer lattice points

This second simulation can be thought of an 'urban walker' where all paths must follow a strictly laid out grid, like some downtown streets. The exactness of the positions means that we can detect with confidence when the walker has crossed back to their starting point. For this simulation, no slider is required - just enter the attributes and add cases.

Using the crossed_start attribute as a filter or to gather measures, you will find that walks often quickly pass over the starting point. You will also find that as you increase the number of cases, the straight 'etch-a-sketch' lines of the urban walk take on very interesting fractal-like contours.
TinkerPlots files for these simulations are here.