Sunday, January 4, 2009

the 300,000th Fibonacci number

I am doing some studying of computational finanacial mathematics. Part of this involves numerical approximation and performance of algorithms.

During this quest I have stumbled upon 2 ways to very rapidly compute the Subject: number.
I guess I could not have imagined what this number might be.

Now as a result of Mma, I can see this number. In scientific notation, it is:

8.761732532916364 E 62695

The first computation is the standard recursive definition. On my machine, this takes 1.422 seconds.

The second computation involves nested powers of a simple 2x2 matrix with 2 column vectors equal to {0,1} and {1,1}. If this matrix is multipled by itself 300,000 times, the 2,2 element contains the number above. On my machine Mma takes 0. !?! seconds to perform this.

Currently I do not know how to make Matlab compute this number. It just gives Inf (=Infinity?!).

A transcipt log is stored here.

Regards..
----------------------------
Originally posted 7/13/2007 at http://www.congruentialuminaire.com/cLBlog

Friday, January 2, 2009

Idiom: obtaining property values from built-in lists

Example: CountryData[#,"LifeExpectancy"]& /@ CountryData[]

This type of idiom appears frequently in the Mma What's New pages.

An explanation of this appears here.

Roger Williams
Franklin Laboratory

Idioms: similar to "patterns of speech" for code

The main purpose of this category of posting is to learn often-used styles of Mma coding. I learned the majority of these by reading the code written by Maeder, Trott, Wolfram & Gray.

Sometimes they are used for their economy. In other situations they can just be quickly recognized and even if they are not shorter, they are shortcuts for the reader. They are often but not always in the functional propgramming style.

Unfortunately they mainly server this function for the initiated. This postings in this cateory attempt to broaden this audience.

Roger Williams
Franklin Laboratory