Beyond Excel

Speed of calculation

If speed of calculation is a priority, you need to move away from Excel
I was pleased with the improvements I had made to the speed of my pi macro. But looking at other web sites, it was obvious that the calculation could be done much faster. Was it my computer, the algorithm or Excel?

Reading C files
Some web sites offer C files to download. These have a file extension c or h. They are simply text files and you can read them using Notepad. If you can follow the code in C, or if there are explanatory comments, you will be able to see the algorithm being used. In order to run the file, you need C on your computer.

Installing C
I thought about getting C for Windows but I wasn't sure I would use regularly. Another option is to install Linux. You can buy a book or magazine about Linux and often it will include one or two CDs that contain all you need. Alternatively, you can try a full Linux distribution in a box. It is worth checking the current version number on the internet as I noticed plenty of older versions on sale in the shops.

Speeds for pi
Now that I had C on my computer I was able to compile and run the files I had downloaded from the internet. I was astonished at the speed differences.

Calculation times in seconds
50,000 decimalspiroot 2e
Excel VBA1,401356288

Sources for the times above:

  a) Excel VBA - using my file shown on this web site
  b) C - using Xavier Gourdon's "classical approach" files
  c) Pifast - using Xavier Gourdon's PiFast (in Windows)

The calculations were all done on the same computer. The Excel and C calculations used almost identical algorithms. So presumably the difference in speed is caused by some basic difference between C and Excel VBA. J-Walk's blog has a discussion about a compiler for Excel and whether there are situations where the speed gains are of practical use.

Factorisation of big numbers is another problem that can require many calculations to find the answer. I had a go at a simple version in Excel but I have not put it on this web site because it was much too slow. Jim Howell has a factorising program that works in a DOS window using trial division. The program file is amazingly small and it is much quicker than the one I wrote in Excel.

For more heavyweight factorisation Pari-gp is impressive. It came as standard with my Linux distribution but you can also download it from the internet.

* Linux is available in a number of different distributions eg SuSE, Red Hat, Mandrake
* home