Slashdot Mirror


Use of Math Languages and Packages in Research?

CEHT asks: "As a research programmer at the university, I have encountered numerous times when I need to choose which language(s) or package(s) to use for different projects. Tradeoffs and performance issues have to be considered: results from one package may be more compatible with the data from other researchers, another package may find the solution faster and use less resources, and so forth. Maple, Matlab, Magma, and Mathematica are among the most well-known packages. Libraries such as IMSL is also popular. Of course, there are smaller (and mostly free) packages that tend to target specific types of problem, such as LiDIA, Singular, and LAPACK. The question is, how useful are these [and other] math packages? Do researchers use only one or two packages for most of their projects? Or do people like to mix things a little by pulling the strength of different packages together to solve a math problem? If not, do researchers write C/C++ programs and use GMP or Matpack to solve math problems?"

23 of 454 comments (clear)

  1. Octave by tanpiover2 · · Score: 4, Insightful

    Whenever I need to do anything like that, I use Octave.

    --

    But masters, remember that I am an ass: though it be not written down, yet forget not that I am an ass.
    1. Re:Octave by s20451 · · Score: 4, Insightful

      Octave is a great idea, but also a gigantic pain in the ass. I don't think I have ever successfully compiled it without serious tweaking on any system I have ever owned. The Octave team needs to spend a little time improving their configuration and make files before that package can be considered a serious alternative to Matlab.

      --
      Toronto-area transit rider? Rate your ride.
    2. Re:Octave by Karn · · Score: 4, Insightful

      Actually, I think you have it backwards.

      First, Redhat (I'm sure other distros as well) INCLUDE OCTAVE. That's right, you don't NEED to compile it because it comes with your distro. You can't get much easier to install than selecting the package at OS install time.

      Second, Octave doesn't require a user to jump through 8 hoops to run it on your system. No FlexLM, no licence files, no keys, no giving Mathworks your hostID when you change computers, etc.

      Finally, most people don't compile from source. And those who do are usually experienced enough to figure out how to get things compiled.

      --


      Why do I keep typing pythong?
  2. MathCad? by Joe+Jordan · · Score: 3, Insightful

    Now, I'm only in college, but while we did dabble a bit in Maple and a few others that you mentioned, the only Math software package I've used extensively is MathCad. I've found it to be the most user friendly of the bunch, and they have a new version out: MathCad.com

    1. Re:MathCad? by Big+Mark · · Score: 3, Insightful

      MathCad is far too limited in power and scope to be of any real use. Maple is my package of choice; admitedly it's hardly the most intuitive or user-friendly software around but hey, neither's Linux. Give it a few weeks of tinkering and you'll learn to love it.

      I want to learn how to use Matlab more effectively as it's (apparently) the most effective for physical modelling, but we don't get taught it over here (Mathcad, Maple and Mathematica are all these scuzzers will teach us); anyone know a good intro to it on the web?

      -Mark

    2. Re:MathCad? by CEHT · · Score: 2, Insightful

      MathCad is probably good for undergrad / highschool math problems, but I doubt it will do stuff like nullspace calculation with a 200x200 matrix.

      --

      ============
      Mathematics will always come back to hunt you down, in so many ways

  3. [none] by WetCat · · Score: 2, Insightful

    "If not, do researchers write C/C++ programs and use GMP or Matpack to solve math problems?"
    No! They use FORTRAN!
    Surely it's still much better language for numeric stuff

  4. For our research... by JWyner · · Score: 2, Insightful

    I find that each package is well suited for a particular use...

    MATLAB is great for off-the-cuff research. I can open it up, and program image processing routines in 30 minutes or less. This would take hours in C/C++. Additionally, I can take the M-file and dump it from my computer onto a workstation running MATLAB and get some decent speed and batch processing done.

    C/C++, however, gives you so much more control and execution speed, that often you either use the MATLAB --> C compiler, or end up writing a final routine in C directly. I believe for image processing, as an example, you can get over a 100x speed increase just by using the MATLAB --> C compiler.

    Just my $0.02.

    --
    "Owning a computer is like having your very own TV -- with a built in radio!" - Ed Helms
  5. Re:Maple sucks.... by coult · · Score: 2, Insightful

    Explain to me how you would do calculus with matlab?

    --

    All is Number -Pythagoras.

  6. Matlab, C, VB, local scripting by pz · · Score: 4, Insightful

    Having traversed from a predominantly engineering realm (computer science) to a predominantly scientific realm (neurobiology), my observations have been that the tools are selected mostly on habit or previous knowledge rather than fitness for use.

    The most commonly-used analytical platform is probably Excel (or some similar tool like Statistica), but the more serious researchers, who are also the more mathematically-aware, nearly all use Matlab in my experience.

    When efficiency is an issue, nearly everyone I've worked with turns either to IDL (a Matlab competitor that has more arcane syntax, but much higher processing speed) or writes a C/C++ program by taking algorithms from "Numerical Recipes in C".

    Recently, I've also seen a rising use of Visual Basic, especially to do experimental control (although some Matlab hooks do exist for such), and, of course, LabView. Some diehards use LabView for data analysis as well, but their results are suspect just because the tool is so poorly fitted to the task.
    And, of course, many data collection hardware manufacturers (CED, National Instruments, TDT, etc.) supply scripting languages to control their hardware and perform rudimentary and sometimes not-so-rudimentary calculations.

    The best researchers select the most appropriate tool for the job, but, again in my experience, it seems the selection is normally based on previous experience and inertia. Those who know a particular tool well (eg, Excel, Matlab, SPSS, Mathematica) tend to keep using that tool, even if it is not well-suited. This means you get abberations like Matlab programs that control real-time experiments and LabView programs that do higher-order mathematics.

    Why?

    Because the largest fraction of a scientists' time should be spent on data collection, not experimental implementation, and the amount of time (for nearly all fields except those with astronomical amounts of data) spent executing code is dwarfed by the time developing it. Clearly this breaks down for certain applications, but most of the science currently being done (read: molecular biology, and no, not bioinformatics) is not algorithm-bound.

    Since data analysis is such a huge, broad field, I expect to see radically different answers from other posters!

    --

    Put my fist through my alarm clock with its ding-dong death inside my ear. - The Blackjacks.
  7. A problem I've struggled with ... by Somnus · · Score: 2, Insightful
    I've used a number of different packages, with varying results. Here are my thoughts:
    • Mathematica -- It's good at everything: symbolic computation, statistical analysis (esp. if you deal in intricate error propagation, where symbolic computation is handy), visualization (w/ some tweaking), and even number-crunching. Has a fantastic built-in library. However, it is a blackbox solution (and I have encountered errors in the past), is awfully slow (can be sped up by accessing the kernel directly through C) and closed source.
    • IDL -- Great for crunching through large amounts of data for the end-user because it has optimized implicit array math. It has an extensive built=library and is good at producing visualizations. Drawbacks are: blackbox (though it uses well known algorithms out of Numerical Recipes, for example), closed-source, and runs best on Windoze, and has an arcane syntax which is some bastard child of Pascal, Fortran and Perl, but not too bad when you get used to it!
    • Maple -- Has all of Mathematica's weaknesses but cannot match its built-in capabilities (plotting, extensive symbolic library, statistics, numerical analysis).
    • Matlab -- Only suitable for numerical computation, and is neither as easy to use nor as replete as IDL.

    Are there any viable open-source solutions to either Mathematica or IDL?
  8. Re:Mathematics past by doctorwes · · Score: 3, Insightful

    Yes, they did calculations by hand. Mathematicians were more patient in those days. For example, in 1863 Kulik published a table listing the least prime factor of every number less than 100,330,200. It filled 4212 pages and took him twenty years to complete.

  9. C and Python by grahamkg · · Score: 2, Insightful

    I do lots of geometric work and I depend on vector math.

    If I'm not concerned with speed, Python is very nice as I can reuse a module package I wrote that contains my most often used functions. Additionally, the fact that Python is OO is also very helpful.

    For speed, such as when I do 10^12+ math operations, I fall back to C. Nothing crunches numbers faster.

    Python and C. They're not just for breakfast anymore.

    --
    Graham
    Linux - Fast Pane Relief
  10. Re:Inexact floating point calculations... by sckienle · · Score: 3, Insightful

    It's been a while since my Senior Independent project, but it was on products like these. I did a lot of the symbolic maths on the packages to describe and document what they were doing. As part of that, I had to look into how they handled floating point errors. I don't remember the package I was specifically working with; and my copy of the SIP is at home.

    With that as an introduction, for the "pure computational" packages,the problem you point out is real. Floating point errors when ignored will slowly move further and further into the significant digits of the FP calculations. For a package to be even reasonable, it must be able to describe in mathematical expressions and textual dialog how it will manage FP errors to keep them in the least significant digits of the number. If you review a package, look and ask specifically how the package does that.

    Some may ask why is this important, don't modern languages handle all this according to the FP Specs? Well, basically the specs are not good enough for large computation tasks. When you start multiplying several matrices together, you end up doing so many FP operations, that without carefully written and mathematically backed code the errors will pratically zoom "to the right." This is compounded by the fact that not all chips comply with the specs in exactly the same way, most of these packages will have a lot of conditional code to handle each chip set's specific particularities. Something else to look for: if a package claims one size fits all, and doesn't talk about OS and HW specific compiles, take extra care checking the FP issues out. They may be taking a worst possible processing approach, which will work but at the expense of speed, or they may be taking a more "mean" processing approach, which may end up with different results on different OS and HW combinations.

    Now, after all that, the reality is that most of these packages, at least if they have been around a while, have the mathematical grounding and programming "backgrounds" to handle FP operations pretty darn well. After all, this was a fairly well known and documented issue back in 1983 when I wrote my SIP.

    The "symbolic" packages seem to side step this by first taking the equations and modifying them in "symbol" form before performing their calculations. Thus, the differential of X^2 is changed to 2x by the program before any FP operations happen. But this does not mean that FP operations do not occur. If your equations still deal with matrices, then a lot of FP operations will have to be done to come up with a numeric answer, no matter what.

    --
    I don't see things in black and white; I see the gray. Heck, I actually see in color, which makes things more difficult
  11. learning softwares vs. coding .. by MenAtWork · · Score: 2, Insightful

    I have been using matlab, mathematica, maple and mathcad for different purposes in university and currently in job. I feel matlab by far is the best of the bunch simply because it allows for a more powerful simulation experience using simulink. Here is what I feel about learning these packages vs. coding ...

    1. matlab - hard on newbies' but very powerful and elegant in the hand of intermediate and advanced users. Graphical simulations possible through simulink. Matrix computations are very fast!! and on average it takes the least amount of time to solve the problems compared to mathematica, mathcad and maple.

    2. mathcad - the first mathematical software I used, very easy to learn almost instantaneous learning!!! but that was when mathcad was still in dos mode, I saw the windows version out now and they seem to be cumbersome to get around, but then I have not been using it regularly.

    3. mathematica and maple - almost similar performance, mathematica has better interface and with a large amount of tutorials and extensive help system is easier to learn than maple.

    4. scilab - a matlab clone which is GNU (I think!!) used it couple of years back when it was not as good as matlab graphically ... maybe its better now ...

    Now, coding - yes it has to be done from time to time but I think due to these softwares it has been relegated to the sidelines when extensive run times are involved and a significant performnace gain can be derived by days of coding. I belive it may be easier given the tons of free libraries available but it still takes longer to code in c/c++ than in a 4GL (generation language) like matlab and mathematica.

    Coding still can't beat the quick prototyping mode of these softwares i.e u can do a lot of manipulations in the time u take to write and debug the code. It basically boils down to whether result or way of getting result matter most !!!

    and then don't forget sometime those big screen scientific calculators are faster to get quick results than u'r fancy softwares and codes :) ob' it may not stand the test of u'r research !!!

  12. Matlab is a jit compiler now by js7a · · Score: 2, Insightful
    Perhaps matlab has evovled a lot

    Yes, indeed, the latest version (from less than half a year ago) was the first to include a just-in-time transparent compiler by default. Inner loops are so much faster than the old interpreted versions it's not funny.

    However, a Matlab clone called MIDEVA had the same thing three years ago. Mathworks bought them out and incorporated their tech.

  13. Use the right tool... by chhamilton · · Score: 2, Insightful

    ...for the job at hand.

    I'm a graduate student in Mathematics studying (convex) optimization problems so I see a healthy mix of pure and applied math. When I'm doing pure math the best tool for the job is a strongly symbolic math package like Maple (which I use extensively). Maple is also really good for quick visualization and helps gain insight and intuition into problems. Other offerings in this arena include Mathcad and Mathematica (however Mathcad actually uses a smaller version of Maple's symbolic engine).

    Similarily, if the task is more numeric, Matlab is the choice (actually, we use Octave, which is a GPL'd and free numeric package that has Matlab syntax; most code written for one runs in the other). I'd say Matlab/Octave are most useful for prototyping numeric algorithms, and solving medium sized numeric problems.

    Finally, when a tool is needed that performs well at one specific task (or the problem size gets really large), you can't beat writing your own tools from scratch in the compiled language of your choice. At this point, there are a variety of libraries that one may find useful (for arbitrary precision arithmetic, expression parsing, symbolic manipulation, etc).

    So I guess the answer isn't white or black, but rather varying shades of grey (as is always the case).

  14. PARI by jasuus · · Score: 2, Insightful

    If you have lots of money, use Mathmatica. If you are poor, use PARI.

  15. Re:Maple sucks.... by Anonymous Coward · · Score: 1, Insightful

    Maple and Matlab serve fundamentally different purposes. You can say that one is better than another for a particular application, but trying to compare them in general is like apples and oranges.

    Maple and Mathematica use symbolic representation, and imho that makes them much better for tools in a calculus class. They will be able to integrate and differentiate and produce results that look like Math instead of a bunch of numbers.

    Matlab is entirely numerical. It will only give you numbers as answers, which can be very nice if you only need an approximate result good to a known tolerance for a problem that CAN'T be solved exactly.

  16. Phew! by jefu · · Score: 4, Insightful
    This is not a small question.

    First a global kind of classification.....

    octave/matlab... are mostly vector/array oriented languages and are useful for doing work in problems that are suited for such - you can experiment easily, then recode in C,fortran... if needed. apl and j are also in this group and should not be ignored - though they're used a bit less frequently.

    Macsyma/mathematica/maple/maxima/derive are symbolic math languages and can solve interestingly sized problems and get symbolic answers (that is, things like sqrt(pi/2)) as well as numeric approximations. This can be a very useful tool to have - depending on what I'm doing I use such things a couple times a week (nice to check results done by hand, or to handle all the crufty part of a solution). Most will emit fortran code which can also be useful.

    vtk, opendx/khoros(?) are visualization tools - most of the other packages have some visualization tools packaged in them, but vtk and opendx both offer quite a bit more power.

    Now the incredibly non specific recommendation

    My suggestion is to pick one of each of these and learn it - do enough in it so you know the language/system well. Otherwise you'll be struggling with the language as well as with the problem - and finding bugs will be close to impossible.

    If I put on my "computer science professor" hat (probably a wise thing if I'm to keep the top of my head from turning bright red with sunburn), I usually try to recommend that all CS students learn a smattering of these things as well. When you need one of these tools, knowing its there and how to use it can save large and wonderful quantities of time.

    And now some more specific comments

    On the whole my choices would be as follows - note the caveats - some of them are pretty cave-rnous (sic). I don't have piles of money to spend, so tend to prefer the open source programs just on that basis.

    For array/matrix manipulation I much prefer APL or one of its derivatives (check out aplus on sourceforge). Languages in the APL family are also fun to program once you learn how. However the terseness of the syntax (and with APL itself the odd character set) tends to make these a bit forbidding, so a more popular choice would be octave (open source) or matlab. I've had good luck with octave - it seems to handle most matlab programs well enough. If you've got piles of money, go for matlab.

    For symbolic math, maxima (sourceforge) is good. Its commercial cousin Macsyma has usually ranked as about the best symbolic math packages for accuracy and power and seems less expensive than the others. Actually writing programs in either of these requires learning quite a bit about the innards of the system though. My second choice for symbolic math would be Mathematica - its programming language is well integrated with the system as a whole and and for general goodness and niceness of the interface it can't be beat. (The other commercial products are building on the best parts of the Mathematica interface - I've not checked recently, but they're getting much better fast.) The visualization capabilities of Mathematica are also very good. Maple is probably the most popular, so using it will probably make it easier to find someone to help you, but on the whole I've just never found Maple as easy to program as Mathematica and I tend to want to program almost everything.

    For visualization both vtk and opendx are very nice systems. vtk is more aimed at a programming interface, opendx has a labviewish kind of programming environment. I like both and have both at hand. Both these systems are big enough that you'll want to make sure you understand them before you tackle a project with them.

    They don't scale well, but spreadsheets can be very convenient for small models. Careful though, its easy to have errors even in middlin sized models that can be very hard to find.

    Odd Zen Endz

    As has been noted there are other systems, some smaller, some more specifically focussed on a single domain. Those tend to be harder to match to a problem - unless the problem is right in the center of the domain in question.

    There used to be a program AXIOM which had a lot of nice features, but it seems to have gone to that Big Bit Bucket in the sky - but its base language "Aldor" is now available at aldor.org. I have a copy, but haven't looked deeply at it.

    Sourceforge is also hosting a new project "lush" - which is a lisp system that has some integration of some of these features. To the extent that I've used it I'm impressed and will probably spend some time working deeper with it in the hopes that it will prove another valuable tool.

  17. SciPy is the way of heaven by Anonymous Coward · · Score: 1, Insightful

    As you've probably figured, there isn't one answer.

    If speed (and being a black box) isn't an issue, Mathematica is probably the best symbolic math package (SciLab as free alternative) and MatLab the best numeric package (Octave as free alternative). MathCad gets honorable mention as very easy to use, but not better than either Mathematica or Matlab at either symbolic or numeric math.

    If speed (and knowing what's going on) is an issue, there is enormous amount of freely available high-quality code (mostly in FORTRAN) on netlib. My modus operandi in grad school was to look for what kinds of algorithms existed in Numerical Recipes and then grab a good implementation from netlib and wrap the fortran with C.

    If I were still doing scientific computing, I would do as much as I could using Python. It is obscenely easy to make Python modules (especially with tools like f2py) from existing code. The approach is to increase the power of the Python interpreter by packaging all that great freely available FORTRAN code in Python modules. The good news is the SciPy project (www.scipy.org) has already made great strides and you can steal their work. Better yet, make your modules available to the community and everyone benefits.

  18. Matlab vs everything else by the_pooh_experience · · Score: 2, Insightful

    So from what I have read from most others' posts, there are two camps:

    1. Use several packages depending upon application... i.e. Mathematica for symbolic math (what it is good at) and Matlab for numerical matrix math
    2. Matlab is good but expensive

    While I agree with #2, it does not really seem to answer the question. The question is: "Do researchers use only one or two packages for most of their projects?" I think the result for the most part is for mathematical calcs, the people that answered the question say most people use different programs for different goals.

    Things to think about when you are trying to pick a language:

    • How big will this get? Are we talking about 100's or 1000's of lines of code? This may filter out some languages.
    • Is this a simulation/calculation that you will be running over and over? This will help decide on efficiency of the language (especially on big projects).
    • Will others be using this code? If this becomes a group project or used by a bunch of people, maybe doing it in a common language will help.
    • If large calculations are necessary, ARE MULTIPLE PROCESSORS NECESSARY? This is a big question for larger code. Certain languages (Matlab to name one) don't naitively support SMP, while other packages (IDL to name one) do.

    These are likely to be very similar questions a computer programer asks him/herself when they are starting a new project. Okay, this post really doesn't say anything, but one last note for the major commercial packages: most of them support C/fortran/etc calls so if you are truely interested in efficiency, remember coding efficiency matters too. I am finishing up my Ph.D. Years ago, when I starting simulations for my work, I started working in C. I figured "if I am going to be working on something for X years, I may as well do it right!" While a noble goal, I really didn't know C. I subsequently spent a week trying to do something that took me roughly 2 hours to accomplish the same thing in Matlab (another language that I had no experience in).

    So what is the moral of the story?

    run... run as fast as you can and don't look back.

  19. Invent by spectatorion · · Score: 2, Insightful

    Well, some did anyway. For example, in the early 1820's, when dealing with solving partial differential equations arising from heat conduction, Joseph Fourier came up with the foundations of Fourier Analysis, which has become an essential tool in a great deal of mathematics, science, and engineering. Where would we be today if he could just plug it into MATLAB and get an approximate numerical solution?

    Also, although I do not really know how he did it, I belive that Euler had calculated e to 7+ decimal places in the mid 1700s.