In a previous post I wrote about how Fermat scribbled his famous “last theorem” in the margin of Diophantus’ Arithmetica. This is called Fermat’s last theorem not because it was the last thing Fermat wrote but because of all the incomplete theorem’s we know were left by Fermat it was the last to be proved, taking about 350 years.

The section of the book where Fermat wrote his comment was on finding Pythagorean triples: square numbers whose sums also form squares. Such numbers can be the sides of Pythagorean (right-angled) triangles, the most well know being 3-4-5.

Graham Wheeler on #mathjax,

Imagine an infinite grid filled where each square is initially either black or white. On this grid is an ant, which can face either north, south, east or west. The ant moves over the grid according to the following rules:

• it it lands on a black cell it turns left 90 degrees; if it lands on a white cell it turns right 90 degrees
• in each case the cell it just left changes color to its opposite (white to black or vice-versa)

Graham Wheeler on

In the late 1980s I was contracted to write some software for a company that produced video-based educational systems. They had video cassette machines that had been modified to interface with a PC, which could send instructions to the VCRs such as play, stop, fast forward, and rewind. The educational programs consisted of short recorded segments which typically ended with a question, and based on the answer the user provided they wanted to continue play at different portions of the tape. The software they wanted me to write was meant to be able to be given a current position (i.e. play time) and advance to a new position. For example I might be told that they are at minute 8 currently and want to resume play at minute 12.

Graham Wheeler on #mathjax,

My 5 year old daughter wanted to heat something up in the microwave. I suggested she use a minute, and she asked me how to enter that. I said enter 1, 0, 0, Start. “But when mom tells me to do a minute she says 6, 0, Start”, she responded. I wasn’t sure how to explain to her that 1:00 minute is the same as 60 seconds; microwaves are confusing enough to her as is.

So why are there are 60 seconds in a minute? Why not 100? The answer lies about 4000 years ago, in some of the earliest known mathematics, of Sumeria and Babylon. The Sumerians and later the Babylonians used a sexagesimal (base 60) number system for their astronomy (although they used decimals for day-to-day applications). They had no way to represent non-whole numbers other than as fractions, and 60 was a convenient base as it has a large number of factors; in particular it can represent 1/2, 1/3, 1/4, 1/5, and 1/6 all with whole numerators. In fact sexagesimal notation can be used to exactly represent any fraction in which the denominator has prime factors of 2, 3, and/or 5 (as these are the prime factors of 60), with a finite number of symbols.

Graham Wheeler on #mathjax,

After a huge storm blew up, the ship foundered. Dawn’s light found just six survivors washed up on a desert island – five men and one monkey. The men spent the day gathering all the food they could find – which was just a pile of coconuts. After a dinner of coconut milk and flesh, the exhausted men decided to they would divide the remaining coconuts up the following day, before splitting up and exploring the remainder of the island.

During the night one man woke up and started worrying about whether there would be a disagreement in the morning over the coconuts. He decided to take his share, and divided the coconuts equally into five. There was one left over which he gave to the monkey, then he took his share and hid them away, before going back to sleep.

Graham Wheeler on #mathjax,

In the Indian city of Benares, beneath a dome that marks the center of the world, is a brass plate in which are set three diamond needles, each as thick as a bee and a cubit high. At the time of creation Brahma placed on one of these needles 64 disks of pure gold, each a different size, each resting only on plates of a larger size (so the largest disk was at the bottom and the smallest at the top).

In the temple are priests whose task is to transfer all the disks to a different needle, moving only one disk at a time between needles but never placing a larger disk on top of a smaller one. When the task is done, tower, temple and Brahmins all will vanish with a thunderclap and the world will vanish.

So how much time do we have left?

Graham Wheeler on #mathjax,

I have an MSI Wind on which I run both Windows 7 and Ubuntu. I rarely use the latter but I like to keep it around and with a 320GB hard drive its affordable. I have used both the Windows BCD loader and GRUB as my bootloader at various times (and for those using BCD I highly recommend EasyBCD as the way to configure it). Most recently I've been using GRUB.

Yesterday I installed Windows 7 RC and my boot sector got clobbered by BCD. I had a bit of a had time getting things working again. I first tried using EasyBCD but this time when trying to boot Ubuntu I ended up at a GRUB prompt, and I could not access my Ubuntu partition (more precisely, while "root (hd0,2)" worked, "kernel /vmlinuz" threw errrors and I could not boot).

Graham Wheeler on

Hopefully by now you all have v3.0 of the Live Search client, and are enjoying the new features (web search, weather, and collections). I'd like to talk about collections in this post, but first it is worth mentioning a couple of changes in this version that are less obvious, and overcome limitations I have blogged about in the past:

• we now have Outlook contact integration. From Outlook contacts you can select the "Show on Map" menu option to map a contact. Google Maps contacts integration is still broken, but we can't let that hold us back any longer; we gave them nearly a year as well as explicit instructions on what their bug was; if they can't get their house in order with all that then too bad for them. If you do want to use both GMM and Live Search, then install GMM last. Their bug will cause problems with any other software that installs menu extensions that is installed after them; if the other apps are well-behaved then you can install them before GMM and you should be okay.
• we have put back the ability to enter addresses in the search box. We have a better geocoder now on the back end and are more confident that you will get the results you want when doing this.

Graham Wheeler on

I heard this proof a couple of days back and thought it was fun and elegant. If you draw a circle anywhere on the surface of the earth there will be at least two opposite points that have the same temperature.

The proof relies on Bolzano's theorem, which is an instance of the Intermediate Value Theorem. Bolzano's theorem says that if a continuous function defined on an interval is sometimes positive and sometimes negative, it must be 0 at some point.

We assume that temperature on any path on the earth's surface is continuous. If f(x) is a continuous function, and g(x) is a continuous function, then f(x)-g(x) is also continuous.

So, choose some starting point on the circumference of the circle, and let f(x) be the temperature at the point at offset x clockwise from the starting point, and let g(x) be the temperature at the point opposite that point. If the temperature at some point x is warmer than at its opposite point x', then f(x)-g(x) is positive, while f(x')-g(x') is negative. So, by Bolzano, there is a point where f(x)-g(x)=0, i.e. f(x)=g(x).

Graham Wheeler on

"Assertions are the only reliable form of program documentation" (Charles Hoare)

While I wait for the next release of Live Search for Mobile, I will fill in the time with some posts on tricks I have used in the dim and distant past, before I became a mostly C# programmer. I love C#, but I really don't like the way the C/C++ preprocessor was not included. While preprocessors can be abused, they are also extremely useful (think of __FILE__ and __LINE__, just for starters).

In particular, the preprocessor in C and C++ provides a very flexible assertion mechanism that is much more useful then System.Diagnostics. I'd like to cover some useful ways of using assertions in C and C++. Of course if you're an Eiffel programmer, you can probably stop reading ;-)