Slashdot Mirror


Programming Mathematics?

Adam asks: "I'm an undergraduate math and CS major, and as such, I would like to write some programs that do basic math, from finding perfect numbers to solving basic algebraic equations--just for fun. However, I only have experience with Java, and BigInteger and BigDecimal suck pretty hard as far as writing equations with them is concerned. So, to all you mathematicians and math lovers, what languages do you program mathematics in, and why?"

2 of 64 comments (clear)

  1. Languages for Mathematicians by Mathematicians by epsalon · · Score: 5, Informative

    Mathematiticians have invented a language called ML (Meta Language) which is a functional language in which you can write mathematical formulas almost as you would mathematically define them.
    In the area of functional progamming you should also consider Common Lisp which is a well known functional language used mostly for AI.

    On the properiatry side, many mathematical algorithms get coded in MatLab which provides built-in matrix manipulation and lots of additional libraries (you'll probably find out most of the stuff you want to write is already there...)

    In any case, the progamming language should be tightly fitted to the application.

  2. fortran by tony_gardner · · Score: 5, Informative

    Depends entirely on what you want to do:

    Mathcad or mathematica can to calculations from a graphical interface, but are difficult to program and slow for anything requiring big loops.

    matlab is a higher level language like the two above, but isn't a graphical interface, so it's easier to do things a little more complicated.

    fortran is the mathematical workhorse for small to medium programs with hard maths. The style is reasonably intuitive. In addition, a familiarity with fortran will never go to waste, since the scientific community has been using it for 35 years, and there's a lot of legacy code. There's free compilers too.

    c, c++ are the mathematical workhorses for medium to large programs. In general, better data structure handling than fortran, and fewer mathematical libraries. Most CFD code and indeed most finite element code is written in some brand of c. I think that it would be fair to say that professional programmers know about c, where scientists who do some programming know fortran. There are free compilers for c as well.

    Choose one to meet your project size and execution speed required.