Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Best Language for Applied Mathematics

  1. Aug 10, 2010 #1
    I am currently in graduate school and I work on modeling. The systems I model rely heavily on stiff ODE solvers (i.e. ode15s in MATLAB) and non-linear solvers as well for solving non-linear reaction and diffusion equations.

    So far I have typically used MATLAB for my work, but I feel like this will limit me when I apply for a job, since companies may not be willing to shell out 1000's in licensing fees if they can just use open source products. So, I want to learn another language that will be useful for my modeling work. I have considered C using the GSL, but I want to make sure that what I invest time in will be the best choice.

    What do you guys recommend I should pick? It's not really necessary to have solvers in place. I could write my own if need be. What's really important is being able to manipulate matrices as easily as it's done in MATLAB, and that the language is powerful with a learning curve that's not too bad. I have a fair amount of experience already in C.

  2. jcsd
  3. Aug 10, 2010 #2
    For something like applied mathematics, I think its very beneficial to be multi-lingual in your coding. Everyone who wants to get respect should know C/C++ well; it sounds like IDL might be another good thing to look into for your situation; but it has essentially the same draw backs as MATLAB (e.g. cost).

    See what kind of libraries/packages there are for vector manipulation in C++.
  4. Aug 10, 2010 #3
    It seems that BLAS (http://www.netlib.org/blas/) along with LAPAC (http://www.netlib.org/lapack/) is pretty much the standard for vector/matrix manipulation in C. It has a lot of the same functions/features that MATLAB has.

    Maybe I will just start with that and learn the basics in there. Then I can develop that some more and maybe write some of my own solvers.

    What about visualizing the data? Is GNU Plot the best for graphing my data? Or is there a better alternative? I would like 2D/3D graph support, and the ability to create animated plots (to step through time).
    Last edited by a moderator: Apr 25, 2017
  5. Aug 16, 2010 #4
    Besides GSL, NAG and ROOT also have decent numerical libraries. Nag costs money, but ROOT is free. Oh and there is of course the Numerical Recipes library (which also costs money), but comes with a nice book. All of those are in C/C++. In fact I'm pretty sure I've searched around and found lots of others, but haven't checked many of them out. Mathematica, like Matlab and Maple, is also popular, but not C based.
  6. Aug 17, 2010 #5
    A few years ago I knew a math wiz-kid who swore by Haskell.

    Then there's the stats languages like R -- soon all math will be statistics, no?
  7. Aug 17, 2010 #6
    R is a nice language, I guess even though its focused on stats you could probably use if for finite difference equations and other numerical methods -- linear algebra is still linear algebra, and stats definitely use linear algebra. But it has some issues with looping that would probably make it non-ideal (plus if the methods you write aren't compiled they are going to be slow).

    Haskell looks interesting -- surprisingly large number of libraries for it.
  8. Aug 17, 2010 #7

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    Most companies I know of will shell out the $$ for licensing fees as opposed to using open source, for example my employer will not allow us to use open source codes so that they avoid licensing issues down the road.
  9. Jun 16, 2012 #8
    However, for someone learning there is an open source version of MATLAB. For windows users install cygwin first and then use the installer to install octave. You can also run it in a virtual machine but the virtual machine approach would be better for users who are good at installing things from source.
  10. Jun 17, 2012 #9
    Well, I don't know what applied mathematics is, but since I hear linear algebra and I hear familiar software like Matlab, I figure I chime in.

    By the way, I thought the brains of the linear algebra of matlab was written in Fortran 90.

    I already heard Octave as a possible replacement for Matlab; well, there is also Freemat and Scilab.

    Of course, there is also Python with numpy/scipy/matplotlib...this is what I have been doing lately.

    Recently, I discovered Re-Interact which on top of Python/numpy/scipy/matplotlib, it adds some a-la-Mathcad kind of capabilities where you have worksheets that include the operations and the results and plots all at the same time...you can also go back, change a value and everything gets updated.

    my 2 cents
  11. Jun 17, 2012 #10

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    The original post is a bit old, but it was bumped. So I'll add my two bits.

    The original Matlab was written in Fortran at Stanford. It didn't do much beyond a few matrix calculations plus access to a few LINPACK subroutines. The Matlab we know (and love and hate) now not only does math, it does graphics (very nicely!), it parses M-files (try that in Fortran!), plus a host of other things. One of the very first things the founders of MathWorks did was to rewrite Matlab in C, finishing the task in 1983.

    Nothing compares to Matlab. Yes, Matlab is ridiculously pricey and proprietary, but nothing compares. Nothing.

    Enough about Matlab, except for one final comment: If a employer is so cheap that they won't buy a Matlab license for someone whose job is applied math, guess how cheap they'll be with you, the employee, come raise time? A Matlab license costs a few thousand. You cost the company a hundred thousand, easy. Your salary might not even be close to $100K, but your salary + benefits + employer's share of social security + office space and equipment + other costs almost certainly exceeds $100K/year if you have a bachelor's degree or higher in science, technology, engineering, or math.

    Job interviews are two way streets. Candidates of course need to sell themselves as a good fit and an asset, but they should also be asking themselves if this where they really want to work. Will their 35 to 60 or more hours per week be performed in a nerd's paradise (thank God it's Monday!) or in some kind of purgatory (OMG! It's only Tuesday!) ? Finding out what kind of technical productivity tools a potential employer provides is a litmus test that helps distinguish between the two.

    I agree. Selling oneself to a potential employer is the candidate's #1 job in their resume, during the pre-interview, and during the interview. Being multi-lingual is a huge asset if technical programming is to be a part of the job.
  12. Jun 17, 2012 #11
    Yes, I know, I wouldn't write a parser in Fortran; but...

    Like I said: "I thought the brains of the linear algebra of matlab was written in Fortran 90"...I just went ahead and confirmed that...

    Matlab Version 5.3 was the last one to use a few Fortran linear-algebra subroutines translated to C...after that, they have incorporated the LAPACK set of subroutines which is written in Fortran-90.

    Yes, matlab is very, very nice; but not everyone works for a big company. Programmers are getting younger and younger and starting to program at home before they care for a job.

    Like any other open source projects, the python/numpy/scipy/matplotlib combination lacks a marketing engine with profit in mind...nevertheless, it is gaining popularity, slowly but surely.
  13. Jun 19, 2012 #12
    Hi, I'm new here. Although I'm not a scientist, I did program professionally. So maybe I can post some helpful thoughts sometimes.

    I agree with our friend here who says it's good to know more than one programming language, because for some applications, some languages are better than others. In general, though, I suggest functional programming languages for mathematical applications, the Haskell language, say. Functional programs usually are much shorter than their procedural counterparts, C programs, for instance, and much easier to understand. In fact, functional programming makes program specifications easy translate program specifications into programs because programming in Haskell is much like doing mathematics on paper. Functional programs even prevent many kinds of bug that you may find in procedural programs.

    A functional program makes the computer evaluate expressions. It doesn't tell the machine to change the values of variables. Instead, it replaces an expression with its value. So functional programming languages are great when computations need to happen at the same time, because the language won't let the computer change anything by accident.

    The best feature of functional programming languages may be that compared to the correctness of procedural programs, the correctness of functional programs is easy to prove inductively.

    Here's the surprise: To program in Haskell, you need to be very comfortable with recursion because in that language, there's no way to write a loop.

    Here's an excellent article about Haskell.

    Last edited: Jun 19, 2012
  14. Jun 19, 2012 #13
    Oh, yes, I have heard of functional programming; but I don't know much about it.

    Code (Text):

    In fact, functional programming makes program specifications easy translate
    a program specifications into programs because programming in Haskell is
    much like doing mathematics on paper.
    Really? At the risk is sounding totally stupid, I don't think the way most of us do math on paper directly translates into functional programming which, again, I don't know what is like or looks like...all I know is that my math very nicely can be easily typed 'as-is' into, say, fortran or C...and I don't think I am doing functional programming...am I?

    I thought I heard functional programming, as nice and safe as it might be, requires a paradigm shift for non-functional programmers...which, again, it seems to indicate that the usual way in which we deal with math in engineering school and on paper might not be "functinoal".

    Anyway, not trying to start a flame war or anything, just commenting and would welcom enlightening comments.

    By the way, no need to learn Haskell...functional programming can be done in the versatile programming language of Python :-)

    Here are just a few links



    P.S. Oh, by the way, Bill, welcome to the forum...looking forward to your contributions.
  15. Jun 19, 2012 #14
    Gsal, thanks for welcoming me. I'm happy to be here, and I look forward to your contributions, too.

    You can write functional programs in Fortran and in C. I've written some functional programs in Python, too. Here's a trivial example.

    Code (Text):
    def number_of_integers_in(this_list):
       return len(filter(is_an_integer, this_list))

    def is_an_integer(something):
       return type(something) == type(0)

    def sum_of_squares(from_here, to_here):
       return [n * n for n in range(from_here, to_here + 1)]
    I love Python, but Python programs crawl. JavaScript may be even slower in some respects. Take Javascript. There's no inbuilt integer data type in it because its only numeric data type is double precision floating point. So to compute with integers, you probably need to do plenty of type conversion behind the scenes.

    By the way, everyone, don't expect me to say much about physics now when I'm much more familiar with logic, programming, analytic Thomism and Catholic dogmatic theology.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook