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

4 of 64 comments (clear)

  1. APL - A mathematical programming language by jcwren · · Score: 3, Insightful

    I'm surprised APL hasn't been mentioned. I wrote a few lines of APL a hundred years ago, and it's certainly not as popular as it used to be, but it was designed as a mathematical programming language. A couple of resources, obtained with Google, using this search rule. http://whatis.techtarget.com/definition/0,,sid9_gc i213454,00.html http://www.engin.umd.umich.edu/CIS/course.des/cis4 00/apl/apl.html

    1. Re:APL - A mathematical programming language by renehollan · · Score: 3, Insightful
      Ah yes, APL... the only language in which you can invert a matrix with three characters, one of which is a backspace. (quad, backspace, divide; also known as domino).

      Seriously, though, APL let me do my arithmetical stats course assignments in the 30 minutes before class, many, many moons ago.

      That said, I think that Mathematica or even MatLab would be better suited for what you want to do.

      --
      You could've hired me.
  2. Why? by coyote-san · · Score: 3, Insightful

    Why are you writing these programs?

    If it's to help you understand the problem, you can use any language... and ML or applications like MathLab and Maple are probably best since they allow you to focus on the math, not the programming.

    If it's because you are interested in working as a scientific programmer then you need to focus on the primary languages used in the field: Fortran, C and possibly Ada.

    Fortran, as others have pointed out, isn't *that* bad. Unfortunately most Fortran programmers *are*. Too many people with a scientific background thought "it can't be that hard to write code" and they're right -- it's not hard to write code. It's hard to write good code.

    C is the probably the standard language now, and has the benefit that the skills are portable.

    Ada is now pretty much a niche language, but you may see it at defense companies and it has a cleaner OO implementation than C++. For the same reason, you might see java compiled into native code (e.g., with gjc).

    --
    For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
  3. Re:you have taken numerical mythods right? by msouth · · Score: 3, Insightful
    Just in case (and for any non-math people reading this) Do not write programs to do math brefore you take a
    numerical mythods class, and a theory of computing class.

    You need to understand the limits of numbers on computers, what the error is, and so on before you can write
    a program that is worth touching.


    quite to the contrary, there is no better time to experiement than the present, with your current level of knowledge. You should be messaing around, trying things, seeing what works. Maybe you shouldn't attempt to sell your work as a fast, small competitor to Mathematica, but, by all means, experiment.


    The more you have played around with this stuff on your own, the more you will get out of those classes when you take them. Never let anyone succeed in scaring you away from trying.


    When I was taking numerical methods, I was in there because I had to be. There was another student in there with way less "raw mathematical talent" than me, but who was doing much better at "getting it" than I was because he was going home and messing around with the stuff on his computer. In fact, during the course he noticed an interesting pattern in his graphs, and brought it to the professor. If I recall correctly they published a paper on the result.


    Theory is important, too, but the real way that theory is developed is that people mess around with stuff for a long time, develop some intuition, and then try to formally show that their intuition is correct. In classes they try to do this in the opposite direction--"here's the theory, try to develop some intuition about it".


    You will be way ahead of the game if you already have experience trying stuff.

    --
    Liberty uber alles.