Recently I have been solving some Project Euler problems. I find there are always several ways to do the same thing. For example, one could join two lists like this:
a = {2, 1};
b = {2, 3};
Union[a, b]
Join[a, b]
Which gives
{1, 2, 3}
{2, 1, 2, 3}
So the Union function sorts the element and deletes duplicates. I guess the Join function will be faster, but how much faster? In a loop, would it be more efficient to use Join and DeleteDuplicates at each 100th step?
Is there documentation of the comparative performance of Mathematica functions? Because heuristics as above could be totally wrong, and I don't know how much experimenting it would take to form a good understanding of the complexity of functions.
{Timing[Prime[10000000000]][[1]], Timing[Prime[10000000000]][[1]]}. Also, many of the algorithms use heuristics to switch between strategies when appropriate. – Dr. belisarius Apr 01 '13 at 15:21