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?"

7 of 64 comments (clear)

  1. Functional Languages by Tomah4wk · · Score: 2, Informative

    Funtional languages like haskell are very good for doing maths, especially large dynamic sizedd matrix math. The language has a built in list type (thing self memory managing dynamic array) and the language is functional, so the programming style is very mathematical. If you use an environment like hugs (see google), you can do all your programming and use in the same system, which i personally like alot. Fortran is also popular for engineering types, as i believe it has built in matrix math functions, howeverdont quote me on that.

  2. 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.

  3. Programming maths by d-Orb · · Score: 3, Informative

    I know I'm going to get flamed for this, but here it goes anyway...

    I do use a mix'n'match approach to mathematical programming. Usually, I deal with numerical methods, and in principle, all languages are good. However, I find that using Fortran95 (see, you were going to flame me) I code faster and easily to-maintain code. The compilers (though not Free as of yet, but see the G95 homepage) produce fast code, which is easy to port between my Linux box and the Tru64, Solaris boxen in some of the labs.

    Another good option is python. The numerical extension and the many modules already developed make it really nice (and quite fast). Additionally, you can add C and Fortran routines to it.

    For profiling, I tend to use either Octave or Scilab, and then convert that on to F95

    For non-numerical stuff, macsyma is quite nice

  4. 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.

  5. Maple from U of Waterloo by Capt_Napalm · · Score: 2, Informative

    The University of Waterloo has a program called Maple. It's fairly easy to pick up, available for Windows, UNIX, Linux and Macs, not horribly expensive, and very powerful. There's also piles of add-on packages created by other mathematicians.

    If you're looking for something on the numerical analysis end, try Octave. It's like MatLab but free.

  6. perl and Math::Pari by msouth · · Score: 4, Informative
    There's a mathematician who used to be quite active in developing Perl's regular expression code (Ilya za[something]) who created a Perl module that lets you use a very powerful and extensive mathematical library called PARI. I believe the extension is called Math::Pari, and it's available on CPAN.

    ok, I just looked it up, here's a blurb from the documentation:


    Package Math::Pari is a Perl interface to famous library PARI for
    numerical/scientific/number-theoretic calculations. It allows use of
    most PARI functions (>500) as Perl functions, and (almost) seamless merging
    of PARI and Perl data.


    One thing I would advise you--use visualization aggressively. There was a tendency in mathematics for a long time to de-emphasize the geometrical/physical aspects of systems as being sort of extraneous--i.e., it doesn't matter what the parabola looks like, just what its mathematical properties are. Well, in short, this is stupid. Your visual cortex is an amazingly powerful processor, and it's dumb to tie one of your brain's hands behind its back just because someone a few centuries back had a theoretical axe to grind.

    Always ask yourself "is there some way I can visualize what's going on here?". You will leap far ahead of where you would be otherwise.

    good luck.

    mike
    --
    Liberty uber alles.
  7. Maple! by bje2 · · Score: 2, Informative

    I went to Lehigh University and we had Maple V available on our on campus network...it's an extremely powerful mathematics application...

    it's not really a programming language, but it does allow you the ability to create variables, your own functions, etc...by far the most powerful featues are it's graphing capabilities and it's ability to find integrals and derivatives of equations that you'd never dream of trying to solve by paper and pencil...

    the only downsides are it takes a while to get used to (the manual is huge!), and the program itself is a bit of a memory hog...other then that it's great...

    --

    "Facts are meaningless. You could use facts to prove anything that's even remotely true." - Homer Simpson