Subways of the old Romans

This is very cool. Someone unearthed one of the subway maps used by the Romans. Now we know why they were able to run their Empire so efficiently. And a one-month rail pass cost only IV denarii.

Wednesday answer

Wednesday answer:
Find a copy of J. A. Lindon’s “Doppelganger“.


Colossal Gardner, ch. 3

The last chapter of the arithmetic and algebra section is on palindromes. I absolutely love the “near miss” palindrome at the front of the article, attributed to Ethel Merperson, in Son of the Giant Sea Tortoise, edited by Mary Ann Madden (Viking, 1975) –

A man, a plan, a canal – Suez!

Palindromes can take many forms, from words and sentences that can be read the same forward and backward, numbers that can be rotated, palindromic primes, and even photos of things (like a bird in flight, going from wing tip to wing tip).

Here’s a game. Start with any positive integer. Reverse it and add the two numbers together. There’s a conjecture that you’ll get a palindrome after a finite number of steps.


121  <— End



13431 <- End

There have been papers written on the existence of palindromic primes and powers. You can play with palindromic roots to get palindromic squares, such as 121^2 = 14641.

You can find many of the same language examples in the wiki article. Yreka City in California used to have the Yreka Bakery and Yrella Gallery. Then there was the former premier of Cambodia, Lon Nol. And, you can have sentences where the word order is palindromic: from J. A. Lindon – “You can cage a swallow, can’t you, but you can’t swallow a cage, can you?”

Note: Lindon was a pioneer in the recreational mathematics field of anti-magic squares. In magic squares, the rows and columns all add up to the same number. With anti-magic squares, the sums of the rows, columns and diagonals are all different. He died in 1979.

Challenge: Can you find a copy of J. A. Lindon’s “Doppelganger,” and can you write a longer palindromic poem yourself?

Comments: I love palindromes, and I had a book collection of them at one time. Back when I first had a 4-banger calculator, I’d tried to find palindromic numbers. I’ve never heard of anti-magic squares before, but they could be fun to play with.

Hachette 3D Puzzle Series, vol. 9

(All rights belong to their owners. Images used here for review purposes only.)

Well, it’s been a couple months since I first wrote about Hachette’s new serialized 3D wood puzzle magazine series. Of the 9 puzzles so far, I only had an interest in #1 (because it was the cheapest one, and I wanted to see what the magazine looked like), and #6. Unfortunately, for some reason #6 is the one that sold out right away and I haven’t seen a copy in the stores at all. These things do run $15 each, so it’s not like I really feel a desperate need to buy it over the net, but if I held the box in my hands in the store, I’d probably get it. (#6 is a 3x3x3 wooden cube slightly rotated and designed to set within a restraining dowel peg holder.)

I also liked the look of #9, so I bought the only copy still at the Junkudo bookstore here

(Ad for the display shelves.)

At first glance, “Mysterious Ball” is a puzzle in that there’s nothing saying what you’re supposed to do with it. I pushed and pulled the pieces sticking out of the ball with no effect. Then I checked out the magazine to see what was in it. One of the first pages gave a hint, and another showed the thing fully disassembled. I didn’t even bother looking all that closely at the photos. 30 seconds later, I had it apart, and back together again. I spent another 5 minutes really examining the MB and making sure I knew exactly why the parts moved sometimes and not others. And now, yeah, I can confidently claim that I’ve got it mastered. It’s got a difficulty level of 3 out of 5 stars, which is probably overstating things a bit. I’d say that it’s an “Easy.”

(Philidor article.)

The magazine feels kind of short this time. While the full thing is 20 pages, the outer sheet is detachable and is primarily advertising for the full series, with a page dedicated to the clear shelving structure you can buy for 5,000 yen ($48 USD) to display all the puzzles in your collection. That leaves 16 pages for the actual magazine itself, where you get the front cover, the inside front cover with publication information and table of contents, 2 pages describing the Mysterious Ball, 5 pages of text puzzles plus their solutions, 2 pages on Francois-Andre Danican Philidor, 1 page for the classic painting memorization game, and 4 pages detailing the solution for the Gyro puzzle from volume 8 (which I used to have a long time ago, and felt no need to buy again). If you’re keeping track, that’s just 7-8 pages of useful material (4 pages of text puzzles, the memorization painting and the piece on Philidor). (The solution for the Mysterious Ball will appear in vol. 10.)

(Look at this painting for 1 minute. Then look away, and answer the questions about it.)

Philidor (1726-1795) was a French composer, best known musically for his comic opera, Tom Jones (1765). However, he may have found a longer-lasting fame as a chess player. He’s considered the best player of his age, and had been friends with Benjamin Franklin. He wrote one of the most definitive books on chess, “Analyse du jeu des Echecs” (1749), with other editions in 1777 and 1790, and it went through another 70 editions and had been translated into English, Russian, German and Italian by 1871. He was the first player to recognize the importance of the pawn in the game. The Philidor Defense, Philidor’s Legacy and Philidor’s position are all named after him. In 1882, Amedee Dutacq (music) and Abraham Dreyfus (libretto) premiered a one act opera-comique entitled “Battez Philidor,” in which an impoverished musician has to beat Philidor at chess in order to win the hand of his sweetheart. Although Philidor agrees to throw the match, he gets distracted and wins by accident.

(Example page for the text puzzles.)

Summary: I like the Mysterious Ball puzzle and plan to challenge my students to solve it. I found the article on Philidor to be interesting, and I plan on tackling the remaining text puzzles at some point.

The next puzzle is going to be the cube snake, scheduled for a June 21 publication. This is the same elastic band wrap-around puzzle that I got from the capsule ball dispensers for $2, so I’m not going to buy volume 10. #11 is the Tower of Hanoi. #12 is the “Devil’s Star” (also from the capsule ball series). #13 is “Turn Table,” another scramble/descramble game in the vein of Rubik’s Cube. It’s pretty, so I might get it, although I’m useless with the Rubik’s Cube, so maybe I won’t. #14 is the White Wood Pig, one of the rare 3D burr puzzles that I kind of want to get. #15 is the Devil’s Box, one of only 2 puzzles rated 5 stars. It looks nice, so I might get that. #16 is a set of wooden disks with color markers that you’re supposed to align so the colored dots match up on all disks. It’s kind of a Penrose tile game, so I might get that, too. #17 is the Cross Piece Cube, which is similar to one of the other capsule ball puzzles. And #18 (the series might go past 18 volumes, but there’s no confirmation of that) is the Devil’s Molecule, which also looks pretty. At the moment, I’m mildly interested in #13 and #16, slightly more interested in #14 and #17, and will probably definitely get #15 and #18. But, these are coming out one every 2 weeks, and, again, they’re about $15 apiece. Even if I do get the ones listed here, the first one won’t hit the shelves until August. See you then.

Ch. 2 Solutions

Number of regions that can be made for a pancake of n straight cuts:
1/2 * n * (n-1)

Number of designs for n beads of 2 colors:
There’s no way to solve this with finite differences. It has to be approached with a recursive program.

Number of triangles for n straight lines:
You need 3 lines to get one triangle, so
0 1 2 3 4  5 : Lines
0 0 0 1 4 10
0 0 1 3 6
0 1 2 3
1 1 1

Assume that no two lines are parallel, and no more than two intersect at the same point. No three lines can form more than 1 triangle, and any set of three lines must form one triangle. The problem becomes similar to: How many different ways can n lines be taken three at a time. The answer can be found using Newton’s formula, as 1/6*n*(n-1)*(n-2).

Comments: Finite differences can be fun. Pick something you can measure at fixed intervals (car speeds or distances, average numbers of cars on the freeway during the day, prices of haircuts at different hairstylists) and see if you can find patterns for them as a factor of n.

Colossal Gardner, ch. 2

Chapter 2 is a continuation of the section on Arithmetic and Algebra.

This time, we get the Calculus of Finite Differences. This concept was first published between 1715 and 1717 by Brook Taylor, who developed the Taylor Theorem. Finite differences are an early form of integral calculus, and the idea is to look at the results of an equation in steps, effectively taking the differences of that equation at those steps to determine the underlying properties of an event. It’s not an infallible way of building up equations to explain specific behavior, but it’s a good starting point in many cases.

Gardner describes a “mind reading” party trick used by W. W. Sawyer, who taught math at Wesleyan University. You ask someone to think of a quadratic equation, with no powers greater than x^2 (to keep things simple).

For example, use 5*x^2 + 3*x – 7.

You ask the person to give you the answers for x = 0, 1 and 2. You can turn your back on them so you can’t see them working the math. In this case, the answers would be -7, 1 and 19. With practice, you could do the following steps in your head in a couple seconds.

The process is to write out the answers in a row:
-7 1 19

Subtract the number on the left from its neighbor to the right and put the results on the next row:

(1 – -7) = 8, and (19 – 1) = 18
8 18

And do the same thing to build up the third row.

18 – 8 = 10

-7 1 19
8 18

The original equation can be built up by the following rules:
The coefficient for x^2 is 1/2 of the bottom number.
The coefficient for x is the first number of the middle row minus half the bottom number.
The constant is the first number of the top row.

a*x^2 + b*x + c
a = 10/2 = 5
b = 8 – 10/2 = 3
c = -7

The calculus of finite differences is a study of these kinds of equations. It had been further developed by Leonhard Euler and George Boole (creator of boolean logic) but fell out of favor in the 1800’s. In the later 1900’s, it became useful again for use in statistics and the social sciences. You can determine the gravitational constant this way. Time the fall of a stone and record the distances at one second intervals:

0 16 64 144 256
16 48 80 112
32 32 32

distance = 32/2 * x^2 + (16 – 32/2) + 0 = 16*s^2

There’s no guarantee that this equation holds absolutely in all cases, but it’s one way to start approaching the development of a theory.

I’d done something like this myself many years ago when I was bored one day, looking at the differences of different strings of powers:

1 4 9 16 25 36
3 5 7  9  11
2 2  2  2

1 8 27 64 125 216
7 19 37 61 91
12 18 24 30
6  6  6

So, I’d discovered finite differences without having any idea what it was. Note that as you get higher powers of x, you get more lines on the pyramid.

Gardner gives a couple additional puzzles to play with – What’s the maximum number of pieces a pancake can be cut into by n straight cuts? How many different designs can you get when making circular necklaces of n beads of two colors (the beads are white or black). And, what’s the maximum number of triangles that can by made with n straight lines?


Coconuts answer

There are actually two variants for the coconuts puzzle. In the older, easier one the monkey gets an extra coconut at the end. Versions of this one apparently go back to the middle ages. The newer version used by William, where the monkey only gets 5 coconuts, is more difficult to solve.

The Diophantine approach is to build up a polynomial as follows (for the older version of the puzzle):
N = 5A + 1
4A = 5B + 1
4B = 5C + 1
4C = 5D + 1
4D = 5E + 1
4E = 5F + 1

N is the original number of coconuts, and F is the number that each of the 5 sailors received at the end. The way to read this is, at the beginning, sailor A divided the pile “N” 5 ways, kept one pile of size “A”, and had 1 coconut left over that he gave to the monkey. Now, there is a pile of 4*A coconuts that is divided 5 ways by sailor B. He keeps one pile of size “B”, has one coconut left over for the monkey, and puts the other four B-sized piles back together again, etc.

If we turn this into one equation by normalizing A, B, C, D and E (i.e. – E = (5F+1)/4; D = (5E+1)/4 = (5F+1)*5/16; etc.) we get 1,024*N = 15,625*F + 11529.

We want the smallest positive value of N such that both N and F are integers. This is easy to do in VBScript as a simple program to run N from 1 to 10,000, but not so easy to derive by hand. (My solution is N = 15,621, F = 1,023.)

One of the interesting things about the Diophantine equations is that some of them have only one solution, others have infinite solutions, and others have none. In our case, the coconut problem has an infinite number of solutions, so we want the smallest one.

However, Gardner presents a twist approach using negative coconuts, which dates back to Norman Manning in 1912. Alternatively, you could take some of the coconuts and paint them blue to be easier to track. The reasoning goes – if you’re dividing up the coconuts into 5 equal piles 6 times, with no leftover coconut for the monkey at the end, then the smallest number that would work is 5^6 = 15625. Now, take four of those 15,625 coconuts, paint them blue and put them in the bushes. This leaves you with 15,621 coconuts, which you CAN divide into 5 piles, with one for the monkey for round 1. Put the four blue coconuts plus the other 4 piles together to make one pile of 5^5 coconuts. This can obviously be divided by 5. But, we pull the 4 blue ones and give the extra to the monkey. In Gardner’s words “This procedure – borrowing the blue coconuts only long enough to see that an even division into fifths can be made, then putting them aside again, is repeated at each division.” After the last round, the blue coconuts are left in the bushes, not belonging to anyone.

The use of blue, or negative, coconuts explains something I discovered when I ran my program. One of the solutions is for N = -4, and F = -1. Adding 5^6 (15,625) to this N gives 15,621, which is the next solution my program found, with f = 1,023. All subsequent solutions have the form N = k*5^6 – 4, and F = k*4^5 – 1 (where k runs from 1 to infinity).

The above description is for the variant of the puzzle where the monkey gets that 6th coconut in the final round of dividing the coconuts into 5 piles. For William’s version, where the last round doesn’t have the extra coconut, the Diophantine equation is:
1,024*N = 15,625*F + 8404

There’s a different general equation that can be used here, depending on whether “n”, the number of sailors, is even or odd:
# Coconuts = (1 + nk)*n^n – (n-1)  : for even n
# Coconuts = (n – 1 + nk)*n^n – (n-1) : for odd n

k is the multiplier used above to get infinite solutions as multiples of N, and for the lowest positive solution, k=0.
For n = 5 sailors,
N = # Coconuts = (1 + 0*5)*5^5 – (5-1)
N = 1*3125 – 4
N = 3,121
The last round of divvying will give 5 piles of 204 coconuts, and nothing extra for the monkey.

Finally, the last puzzle on Monday had three sailors finding the pile of coconuts. The first sailor takes 1/2 of the pile, plus half a coconut. The second sailor takes half of the remaining pile plus half a coconut. The third sailor does the same thing. Left over is exactly one coconut, which they give to the monkey. How many coconuts did they start with?
If you work backwards,
(1 + 1/2) * 2 = 3
(3 + 1/2) * 2 = 7
(7 + 1/2) * 2 = 15
Answer: 15 coconuts

Comments: Man, I never expected this chapter of the book to give me so many problems. I’d initially thought I’d spend an hour writing it up and that’d be the end of it. But, I kept making mistakes in forming the Diophantine equations for each puzzle, and both my math, and my VBScript program kept coming out wrong. I spent close to 2 days on this one.

Obviously, I’m not as good at recreational math puzzles as I’d liked to think I was.

The Colossal Book of Mathematics: Classic Puzzles, Paradoxes and Problems

(Image from the amazon page, used for review purposes only.)

The Colossal Book of Mathematics, by Martin Gardner (2001)
I’ve mentioned a couple times that I received this book for Christmas. It’s a big book (700+ pages, hence the name), so it’s taken time to read it all the way through. Gardner sold his first article to Scientific American in 1952. It was on logic machines, which were used to solve logic problems in the days before computers had come out. His article included a heavy paper insert with cut-out window cards he’d developed for solving syllogisms. The article was expanded and included in his Logic Machines and Diagrams book in 1959. It wasn’t until 1956, though, when he submitted an article on hexaflexagons (folded paper rings that you can turn inside out) that the SA editors were impressed enough to ask if he had enough material to start up a dedicated monthly column for them. “Mathematical Games” started on Jan., 1957, and ran until 1981, for almost 25 years and 300 columns. Colossal contains 50 of the best articles, hand-picked by Gardner, to cover subjects from topology and tiling to time and pseudo-science. About half the articles include puzzles you can try to solve, with answers at the end of each. All have addendums updating the columns with more recent discoveries, and some have reader response letters reprinted with corrections and alternative answers to the puzzles.

It’s a fun, challenging book. I skipped the puzzles on subjects I’m not that interested in, including the ones on topology about how to cut a doughnut to get two interlocking rings. Some of the other puzzles or projects are more time-consuming than what I want to tackle now, but…

I have nothing else to write about on this blog right now. There’s still nothing from Gakken regarding new kits, and none of the other science publishers has anything new out I want, either. So, I’m going to switch over to commenting on each of the articles in the “Colossal” book, on a weekly basis. Some of the comments may be short, just mentioning what subject that article covered, and others may have longer commentary or reprints of the puzzles (including photos of hexaflexagons). If you’re interested in this kind of thing, you may be better served by buying the book (definitely worth the $16 for a new copy). Otherwise, you could think of this series as a “52-week a year calendar” kind of thing, minus 2 weeks.

Ok, getting started. Any minute now. Here it comes. Ready… almost… just about now…

The first three articles are on Arithmetic and Algebra, with number one entitled “The Monkey and the Coconuts.” It centers on a short story written by Ben Ames Williams in the Oct. 9th, 1926 issue of The Saturday Evening Post, called “Coconuts.” In Williams’ story, there’s a simple puzzle that the plot hinges on. Five men and a monkey are shipwrecked on an island, and they spend the first day gathering coconuts for food. The coconuts were all piled up together and the men went to sleep. In the middle of the night, one of the men woke up, and decided to take his share right then. He divided the coconuts into 5 piles, with one left over that he gave to the monkey. He hid his portion, put the rest back into a pile, and went to sleep. Then, one by one, the other 4 men woke up and did the same thing, taking 1/5th of the coconuts, and always having one left over that got handed to the monkey. In the morning, they divided up the last of the remaining coconuts, and it came out to equal shares. Question: How many coconuts were there at the beginning (and by extension, how many were there at the end when they were handed out)?

Gardner lumps this puzzle in with a group of brainteasers called Diophantine equations, which are polynomials, usually with two or more unknowns, for which you want only the integer solutions. They are named after Diophantus of Alexandria, a 3rd century BCE Hellenistic mathematician who studied these equations, and was one of the first mathematicians to introduce symbolism to algebra. The approach Gardner uses is with negative coconuts, thus avoiding the need for a polynomial format. An easier variant of the problem is: Three sailors find a pile of coconuts. The first sailor takes 1/2 of the pile, plus half a coconut. The second sailor takes half of the remaining pile plus half a coconut. The third sailor does the same thing. Left over is exactly one coconut, which they give to the monkey. How many coconuts did they start with?

Answers on Wednesday.


Power Pi

I was asked recently how people calculate PI. That is, what method is employed on a supercomputer to get the value of PI to a specific number of decimal places. I didn’t know off-hand, so I looked it up. Wolfram gives 32 power expansions for PI. For those of you unfamiliar with the math, a power expansion (or power series) is just another way to write out a number as the summation of individual arithmetic operations (i.e. – terms).

The simplest one to implement in VBScript is:
pi = 4 * sum [(-1)^k / (2*k + 1)] where k goes from 0 to infinity in steps of 1.

The (-1)^k part causes each iteration of the formula to oscillate between two points that gradually close in on the correct value. Then the 1/(2*k+1) is the portion of the power expansion that actually contributes to the final value. It’s easy to write, but it is slow. On my laptop, I need to run k up to 5,000,000 terms, and it takes 15 seconds to finish. Even then, the result is only accurate to 6 decimal places.

I tried to streamline the program a bit, so the part where I multiply the result by 4 isn’t until the final wscript.echo statement. Note also that there’s little point in calculating (-1)^k EVERY SINGLE TIME, so I just use sn2 to hold the current value of the sign flipping component.

for k=0 to 500
tmp = sn2/(2*k + 1)

is the same as

for k=1 to 1001 Step 2
tmp = sn2/k

but is maybe 25% faster to run.

res = 0
sn = -1
sn2 = 1
max = 2 * 5000000
for k = 1 to max Step 2
tmp = sn2 / k
res = res + tmp
sn2 = sn2 * sn

wscript.echo “res = ” & cstr(4 * res) & ” term ” & cstr(k) & ” = +/-” & cstr(2 * tmp)

The actual value of PI is: 3.14159265359
My value is 3.14159285359 At step 5,000,000
and 3.14159245359 At step 5,000,001
So, I’m at +/- 0.000000199999.

Not a really useful program, but it is fun to see the answer coming out close.


There’s a more direct method with just two terms (using Excel expressions):

pi = 4 * (4 * atan(1/5) – atan(1/239))

This of course now involves finding the irrational values of two separate numbers to whatever accuracy you’re seeking for pi… Maybe not an improvement.


Many of the formulas described at the Mathworld page are circular, in that to find pi, you have to use pi within the power series. Which to me seems to be kind of hard to do in software. However, I did like the version which comes from the special value of the Riemann zeta function for (pi^2)/6 = zeta(2n) for all positive integers n:

pi = sqrt(6*(1 + 1/2^2 + 1/3^2 + 1/4^2 + …))

In VBScript, this becomes:

t = 0
for n = 1 to 5000000
t = t + 1/n^2
wscript.echo “pi = ” & cstr((6 * t)^0.5)

pi = 3.14159246260382,

This is 29% faster than the first program above (5 seconds for 500 million terms, compared to 6.5 seconds for the first program), and they are both still accurate to only 6 places. (If both programs run for 500 million terms, the first program takes 357.6 seconds, and the second for 255.7 seconds, giving program #2 a 28.6% speed advantage, although #2 was only accurate to 7 places and #1 was already accurate to 8 places.)

After 500 million terms:
PI = 3.14159265359
#1 = 3.14159265158926
#2 = 3.14159264498239

Back to Riemann, Part 19

(plot[gamma(x + i*y) * gamma(x + i*y) x=-10 to 10 y=-10 to 10])

Right after writing up Part 18, I returned to reading the Martin Gardner math recreations book I’d received for Christmas (it’s a big book). There were a couple articles on fractals and fractal sound, and I got to thinking that I’d like to do something similar. The key element to the Mandelbrot fractals is that they’re based on reiterations of equations on the complex plane, and that’s exactly what the gamma function does, so, who knows, maybe performing gamma on itself in some permutation might be interesting.

After spending several days waiting for Excel to slowly grind through each of the animation approaches I decided to try, I gave up. The main problem is that the numbers start out really small and then get extremely big very fast, causing Excel to clip out most of the plots in half of the frames (even when treating the values as logs). So, from an animation viewpoint, gamma has its limitations. But, the Wolfram Alpha plots look interesting, so I’m posting them here.

(Looks like a Nazca drawing.)

(plot[gamma(x + i*y) * gamma(10-x + i*y)) x=-10 to 10 y=-10 to 10])

(plot[gamma(x + i*y) * gamma(x + i*(10-y)) x=-10 to 10 y=-10 to 10])

(plot[gamma(x + i*y) * gamma(10-x + i*(10-y)) x=-10 to 10 y=-10 to 10])

(plot[gamma(gamma(x + i*y))) x=-10 to 10 y=-10 to 10])

With gamma of gamma, Wolfram actually times out. Either it draws only the real component, the real and imaginary components, or just the real contour map. The graph takes too long for it to do all four plots.

(plot[gamma(1/gamma(x + i*y)) x=-10 to 10 y=-10 to 10])

And with this, I’m going to call it quits for gamma for a while.