I always used mathematica for more "theoretical" computations: maybe I had to handle intricated manipulations, but things that you could almost do on paper.

Now I just joined a new project where we will have to handle HUGE (for my standard) computations: maybe simplifications of 400MB output! This time the difficulty is not "coding intricated manipulations", most of the time the thing we really have to do is a "//Together", but the expressions are so long...

I understand that these kind of things cannot be done simply on a notebook, as I always worked: the next simplification make Mathematica crash and I waste a night worth of computations.

So come my question: what are good "coding habits" to have when working in this kind of projects? Are there Mathematica functions I should be aware of (Monitor, Timing, those kind of things)? Also, good references/tutorials on this kind of topic?

I hope the question is not too vague...

  • 2
    $\begingroup$ If the cmplexity of symbolic computations becomes so high then a noteworthy question arises: What can be read off from the results? What insights have you gained in the end if the resulting formulae are not human readable? It might or might not be a good strategy to convert symbolic computations to numerical ones in machine precision numbers (these can be processed faster) and to study the resulting quantitive data. Anyways, Lowe's advice still holds in 2019: "Save early, save often." DumpSave might be your friend. $\endgroup$ Feb 8, 2019 at 9:43
  • $\begingroup$ well, at the very end we will do some numerical analysis. But first we have to get there by doing things "analitically". Thanks for DumpSave! $\endgroup$ Feb 8, 2019 at 9:51
  • 3
    $\begingroup$ "But first we have to get there by doing things "analitically"." I am sorry to say that, but that is a a common misconception. My experience is that number crunching on unsimplified expression (using Compile) is not seldomly much faster than doing the same with expressions that first have been simplified with enormous effort. But of course, this depends on the nature of the actual problem. $\endgroup$ Feb 8, 2019 at 10:14
  • 1
    $\begingroup$ If on a unix-based system, I find that free -m is useful for predicting when I am likely to bring my machine to a grinding halt. Less clear is what will let one know when a kernel might be about to crash. Might want to use memoryConstrained to see if that helps at least to prevent the crashes. Also might want to try simplifying and replacing subexpressions first, if possible. $\endgroup$ Feb 8, 2019 at 17:40
  • $\begingroup$ If possible, avoid getting to the point of having a 400MB expression. Try to simplify expressions earlier in the overall computation. If this is not possible, using Collect together with Simplify, as described here, sometimes is helpful. $\endgroup$
    – bbgodfrey
    Feb 9, 2019 at 5:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.