version: desktop | mobile

Dave's Free Press

the Slightly Less Bad And Wrong Blog Edition

 

Recent posts

Less important journals

Search




Subscribe

rss

Journals that link here

Powered by

Bryar 3.0!
geeky silly politics rant weird meta religion music transport london drinking perl culture olympics photography language cooking hacking web sport media rsnapshot holidays books spam film whisky bryar yapc palm telecoms review bastards cars travel etiquette clothes lolcats amazon maths curry security home unix phone go environment bbc latin anglo-saxon privacy linux gps deafness work
Tue, 22 Jul 2008

Wikipedia: WRONG AGAIN

Wikipedia has a reputation for being of rather low quality, particularly in the humanities. In the sciences and technology it is supposed to be pretty good. But today, I found an error in their article about ... the triangle. One of the most basic mathematical concepts. And they got it wrong. Joy.

OK, to be fair, it's only subtlely wrong, is correct for the majority of cases, and one could argue that the context in which the inaccurate information is presented makes it OK. But I disagree.

In a section called "Basic facts" they first mention that triangles were described thoroughly by Euclid. Good. In the next paragraph, they say that the internal angles add up to 180°. Not so good. They only do so in some spaces, the most commonly known of which is the Euclidean space. Anyway [click click click type click] I've fixed it now. I wonder how long it'll stay fixed, or whether some wanker will revert my pedantry.

Posted at 00:31:44 by David Cantrell
keywords: geeky | maths | web
Permalink | 0 Comments
Wed, 11 Jun 2008

Optimising n!

If you want to add up all the numbers from 1 to n, you can do it two ways. The slow, inefficient way is to calculate:

1 + 2 + 3 + ... + n

The quick way is to remember what you were taught in school, that:

1 + 2 + 3 + 4 + 5 + 6 = (6 + 1) + (2 + 5) + (3 + 4) = 7 + 7 + 7

and that in general:

1 + 2 + ... + n = n(n+1)/2

This optimisation might not matter for small values of n, but for n = 1000000 it really makes a big difference. This got me thinking whether there was a similar trick for calculating the product of all numbers from 1 to n - that is, n-factorial, or n!.

This matters even more for n! because it gets so large so quickly that computers are unable to accurately represent the intermediate values. In fact, 20! is the largest that can be respresented on a 64 bit machine. 21! can only be approximated, as you need to use a floating point number. This means that not only is calculating really big factorials time-consuming, it's not possible at all to do it accurately with native datatypes.

I don't even know if there is a simple re-statement of n! like there is for the sum above, but I'm gonna spend a few idle minutes working on it.

Posted at 20:10:32 by David Cantrell
keywords: geeky | maths
Permalink | 1 Comment

Archive

2007

Jan Feb Mar Apr
May Jun Jul Aug
Sep Oct Nov Dec
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan

2006

Jan Feb Mar Apr
May Jun Jul Aug
Sep Oct Nov Dec
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan

2005

Jan Feb Mar Apr
May Jun Jul Aug
Sep Oct Nov Dec
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan