Category Archives: General

Thinking about sex…agesimal numbers

Ever wonder why our clocks divide hours into sixty minutes of sixty seconds? What’s up with the sixty? I mean, factors of five and ten make some sense, but why sixty? Well, as it turns out, these things have some nifty properties because sixty has so many small factors. 60 = 2 * 3 * 2 * 5. Let’s look at the set of numbers which only have prime factors which are in the set {2, 3, 5}. What do they look like? Well… The first 30 are

1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18,
20, 24, 25, 27, 30, 32, 36, 40, 45, 48, 50,
54, 60, 64, 72, 75, 80

You could get more terms from the Encyclopedia of Integer Sequences if you are too lazy to compute them yourself.

Let’s say that we have a number which we want to divide by a number in this list, say 75. 75 is 3*5*5. Let’s search (it isn’t hard) for a number 60k where 60k is divisible by 75. Well, that’s simple enough, 602 is 48 * 75. How does this relate back to division? Let’s say we want to divide 189 by 75. If we did the math normally, we’d get 2.52. But the Babylonians expressed fractions in sexagesimal notation: meaning that instead of having decimal digits, they had units, 1/60ths, 1/3600ths, and so on. We will write such numbers beginning with the units digits, and colons separating the remainders. A few seconds (minutes if you are rusty) of work on converting the number to radix 60 would tell you that the answer is 2:31:12. But let’s use what we learned above. instead of dividing by 75, let’s multiply by 48 instead. 48 * 189 = 9072. Let’s write this out as powers of 60. 9072 = 2 * 3600 + 31 * 60 + 12. Interesting! By multiplying by 48 and then shifting two sexegesimal digits, we can effect division: in short, we’ve discovered reciprocals. Because all these “regular” numbers have short reciprocals in base sixty, it’s actually rather convenient to use them to multiply and divide. Neat. The Babylonians apparently had good tables of these numbers.

It’s not hard to figure out that if a number x is regular, then its “reciprocal” must also be regular. (If a number is regular, it consists entirely of factors 2, 3, and 5 to some power. The sequence of powers 600, 601, 602… obviously generates arbitrarilly large numbers of these factors, and by dividing out, we are obviously left with 2, 3, and 5 being the only possible prime factors.) So we could just have easily divided by 48 by multiplying by 75 and then shifting by two sexagesimal digits.

It’s an interesting programming problem to find a short program to generate the list of all the numbers which are “regular”, which have only factors of 2, 3, and 5. If you have a lazy functional language which supports proper tail recursion, you can use streams to write a simple but interesting program to do it. I didn’t have either handy, but I did have Python handy. The analogous version didn’t work out too well at generating large numbers of terms, mainly because Python simply doesn’t do proper tail recursion, but in 20 minutes of tinkering with Python managed to hit on a method that worked pretty well using heaps. It took my AMD64 about 15 seconds to generate the first million terms, the millionth of which is 84 digits long.

Regular number – Wikipedia, the free encyclopedia

Addendum: Here’s the python code to generate these regular numbers (I retimed it, and it actually takes 18 seconds on my machine):

#!/usr/bin/env python

from sets import Set
from heapq import heappush, heappop

heap = []
heapset = Set([])

heappush(heap, 1)
heapset.add(1)

for x in range(1000000):
        val = heappop(heap)
        heapset.remove(val)
        print val
        if 2*val not in heapset:
                heappush(heap, 2*val)
                heapset.add(2*val)
        if 3*val not in heapset:
                heappush(heap, 3*val)
                heapset.add(3*val)
        if 5*val not in heapset:
                heappush(heap, 5*val)
                heapset.add(5*val)

Addendum2: A slightly modified version of this code can be used to verify that there 35,084 4-smooth numbers less than 10100, which is the first part of problem 1.68 in Crandall and Pomerance’s Prime Numbers: A Computational Perspective.

[tags]Mathematics, Regular Numbers, Babylonian Numbers[/tags]

Hypermiling: Extreme Fuel Conservation by Unorthodox Driving

We’d all like to get better gas mileage from our cars. Well, me especially. My Ford Expedition isn’t exactly the cheapest car to put on the road. But so-called “hypermilers” take this to the extreme by adopting a number of techniques to reduce fuel consumption: such as drafting trucks with the engine off, or taking slow curves at high speed to retain momentum. I’m simultaneously horrified and amazed. Check out the cool article on Mother Jones.

This Guy Can Get 59 MPG in a Plain Old Accord. Beat That, Punk

Gutenberg Gem: Handwork in Wood by William Noyes

I know a couple of readers of mine are interested in woodworking, so when I saw Handiwork in Wood come by on the recently completed list over at Distributed Proofreaders, I thought I’d have a look. The title suggested a book about the working of wood with handtools, and indeed, the book does that, but it also includes a large section on the working of large lumbermills around the turn of the century, with many photos. Some are really pretty neat, like:

Loggers

It does include a wide variety of information on hand joinery using both simple and sophisticated planes of the day. Worth checking out.

Handwork in Wood by William Noyes – Project Gutenberg

[tags]Wood Working,Public Domain, Project Gutenberg[/tags]

Don Knuth’s Dancing Links and Algorithm X

Tom does probably as much if not as more code tinkering as I do, and his is probably more interesting. At lunch today he mentioned that he implemented Knuth’s Algorithm X for solving the exact cover problem. I couldn’t remember what that was, but I did recall it was related to Knuth’s Dancing Links, which I know my friend Jeff had implemented before as part of his exploration of polyominoes, but I didn’t recall what it was about either. So, to help me, I dug out the link below, which I’ll share with y’all.

Link to the pdf.

[tags]Don Knuth, Programming, Exact Cover, Polyominoes[/tags]

Gutenberg Gem: A Field Book of the Stars by William Tyler Olcott

Need an introductory guide to the stars? You could worse than downloading William Tyler Olcott’s A Field Book of the Stars. It’s not the most detailed, but will get you started in being able to navigate the skies with your naked eyes, a pair of binoculars or even a small telescope. Good stuff, and the price is right.

A Field Book of the Stars by William Tyler Olcott – Project Gutenberg

Taurus

[tags]Astronomy,Public Domain,Star Guide[/tags]

Pi Day – Einstein’s Birthday – A National Science Holiday?

While I was up in Truckee this weekend with some of my old college buddies, David said that his daughter had received an assignment which was to pick someone whose birthday we should make into a national holiday. Their rather excellent suggestion was that Albert Einstein would make an excellent choice. As it happens, Albert celebrated his birthday on March 14th, which has also been designated pi day (3.14 being the first three digits of pi, naturally). Albert Einstein was named as Time Magazine’s Person of the Century, and his name is indeed a household word, virtually synonymous with genius.

It truly would be terrific to have a national holiday which emphasized the role of science in the advancement of society. Einstein of course contributed a great deal to the understanding of the physical universe. In the glorious year of 1905, Einstein published papers which established the existance of atoms, explained the photoelectric effect, discovered special relativity and the equivalence between matter and energy. Not a bad year’s work.

In discussing this, I also thought that the birthday of Charles Darwin (February 12th) might also make a good holiday. Besides it’s close proximity to Valentine’s Day (a holiday carefully designed to perpetuate stereotypes of sexual roles), some of our housemates thought that Darwin would be “too controversial” to make a good candidate. Ironically, I think that Einstein’s political activism was certainly more pronounced than Darwin’s, and while Darwin is demonized for ills which he had nothing to do with, Einstein’s pacifism and support for a one world government are largely ignored. Such are the ironic judgements of history.

Oh well. These thoughts are too big for this tiny blog.

Tomorrow I’ll have some more links and information about Ï€.

[tags]Einstein’s Birthday,Pi Day[/tags]

Addendum: Here’s an image from an old posting.
Albert would have read my blog...

You could make your own if you like.

Reno — a trip of some firsts…

Carmen and I got back from a trip to Truckee/Reno.  She wanted to take skiing lessons, so we did.  We both did well and had fun.  She also took me to the driving range and taught me how to smack balls into the water.  That was fun too.

Carmen Playing Golf

[tags]Vacation[/tags]

Gosper’s Acceleration of Series

While working on my various and sundry Ï€ programs, I kept finding references to Gosper’s paper Acceleration of Series, so I thought I’d find it on the web and have a read. It’s quite the magnum opus of series acceleration with all sorts of gems that are, to be truthful, beyond my understanding. Worth reading, worth studying.

From the abstract:

The rate of convergence of infinite series can be accelerated b y a suitable splitting of each term into two parts and then combining the second part of the n-th term with the first part of the (n+1)-th term to get a new series and leaving the first part of the first term as an “orphan”. Repeating this process an infinite number of times, the series will often approach zero, and we obtain the series of orphans, which may converge faster than the original series.

[tags]Mathematics[/tags]

Cornell University has scans of Scientific American

As part of Cornell Uniersity’s Making of America, they have scans of Scientific American from 1846-1869. Very nice, albeit with their rather obtuse and probably meaningless usage restrictions.

[tags]Public Domain,Scientific American[/tags]

Here’s the full page of an issue which describes Lord Rosse’s telescope (with the illustration below). Oops. That was a link to the gifcache. You’ll have to dig to find it again.

Lord Rosse's Telescope

Billionth Hex Digit of π

Well, after tinkering around with my implementation of the BBP algorithm a bit more, i was able to get it to work out until about 108, but no further. I suspect that some kind of implicit type conversion was happening that was truncating values in an inappropriate way, resulting in loss of precision. So, after grumping about that for a couple of days, I rewrote the basic algorithm again using the gnu bignum library, and ran it last night as I went to bed. In the morning, I found:

Script started on Thu 08 Mar 2007 11:15:07 PM PST
[chessboard] % ./a.out
0.6631159945223164865255091753630803566662e0
0.9631390752150799992020096304874891670995e0
0.2731996222104393979293359647540544136843e0
0.1069573797110732818888081014815876046136e0
pi = 0.5895585a0428b564084e74a23ba96459fb@0
12412.399u 43.758s 3:27:37.39 99.9%     0+0k 0+0io 0pf+0w
[chessboard] %

If you compare this to the digits listed in Bailey’s paper, you’ll see they match, offset by one. It appears that in Bailey’s programs, he counts the initial 3 at the head of Ï€, whereas my program does not. I’m not sure how many significant digits I’m using, I doubt I’m getting much more than about 14 significant hex digits in the result. I’ll do another run, offset by one and see how much they overlap. Total runtime was about 3x slower than my version which used the native floating point formats, which on the whole isn’t bad.

Addendum: Just as a check, here’s my run to compute the 10 millionth digits of π to compare with what I did earlier.

[chessboard] % ./a.out 10000000
0.9529379795180445077636575590185365825231e0
0.2166774963446692996905073127592122197319e0
0.2634515579817620244087507021447804419826e0
0.6346364623910829689209479177718852530542e0
pi = 0.7af5863efed8de97033cd0f6b756186bf9@0
103.966u 0.464s 1:46.88 97.6%   0+0k 0+0io 0pf+0w

[tags]Mathematics,Pi[/tags]