next up previous index
Next: Octave Up: The Expanding Universe Previous: Hints and Comments

   
Interactive Fortran: Octave and Matlab

Fortran is a very nice language, but even for very simple computations you must write, compile, and debug programs. As every Lisp hacker knows, it's fun to work with interactive systems and be able to test various programming and computational ideas as you develop your algorithm.

Two popular problem solving environments exist, which are nearly identical: Matlab and Octave  . The basic difference between them is that whereas a single Matlab license for a PC or for a Mac may cost nearly $2,000 , Octave comes for free  and you get a source code of the whole system to boot, sic!

In this section we won't delve too deeply into any of those systems - this will come with time. But I'll show you how you can perform the computations, we did in Fortran, interactively and fairly quickly using both systems, and how you can display the results.

In principle neither Octave nor Matlab are any easier to use than Fortran, but they come equipped with a very impressive dose of mathematical knowledge, which is built in and ready to use within your interactive session. This way you can cut down on programming very significantly. For example you can simply call an incomplete gamma function, instead of having to code it yourself. On the other hand this is no different from calling an incomplete gamma function from an external library, such as NAG, IMSL, or ESSL.

As you will see below, the total amount of typing that you have to do in Matlab or Octave in order to solve our $\chi ^2$ fitting problem is roughly the same as what you have to type in Fortran minus declarations of variables. But even here Fortran programs can be made shorter still, by defaulting to Fortran's implicit typing  - not that this is a sound programming practice!



 
next up previous index
Next: Octave Up: The Expanding Universe Previous: Hints and Comments
Zdzislaw Meglicki
2001-02-26