Tag Archives: programming

Project Euler

Project Euler is a project that offers mathematical problems that should be solved by computer programming. The problems are easy to understand and a theoretical solution is always obvious. But... a solutions is regarded as acceptable, if the algorithm that is applied lasts at most 1 minute. And of course the problems have such parameters that make brute force inefficient. So the ambitious solver has to invent good ideas or look for some in mathematical books, that solve the problem quickly.

Solving or just dealing with a problem makes much fun, because one experiences the power of mathematics and recalls old or learns knew knowledge.

Recommended to everyone who loves mathematics and programming!

Here is the webpage.

C and octave

Yesterday I tried to compute explicitly some probabilities for a stochastic process relevant to my dissertation about Xenakis and Stockhausen.

At first I tried GNU octave, a high level language for solving mathematical problems. I was quite content computing the probabilities at depth 1 and 2 of the process. Then, at depth 3, it was calculating... I waited almost 40 minutes and then decided to rewrite the programme in C. I wrote it, I compiled it, I ran it and I had the result in a 5'20'' (execution time) while octave was still calculating...

Of course, it is easier to write a programme in octave in order to solve usual mathematical problems (system solving, ODEs) than in mere C, but C with the GNU Scientific Library offers a nice (and very fast) programming "environment" as well.

Here I must admit that the programme was written very fast and badly (without saving middle results, which had to be recomputed at each step when needed). But nevertheless, this comparison says much about the speed of C.

[Then I tried to calculate the probabilities for depth 4 with C; as I expected: 8.5 hours. Bad algorithm. I have to save all middle results and do some calculating preparations (initial results) before the main algorithm...]