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

Running simultaneous computation in mathematica

  1. Nov 27, 2011 #1
    hi
    when i run a heavy computation on mathematica in the same time even if i want to calculate 2+2 , mathematica does not calculate it until calculating of heavy computation finishes.
    why?

    another problem is that when i do a heavy computation and obtain results , after closing mathematica and opening it again mathematica do not remember its calculations in that notebook.
    for example if the result of calculation is a matrix then after closing and opening of mathematica for manipulating that matrix , for example multiplication it by itself i have to run the heavy computation again and obtain the resulting matrix again.
    is there any solution that mathematica without running again a notebook remember calculation of that notebook?
    sorry for my bad English writing.
    thanks
     
  2. jcsd
  3. Nov 27, 2011 #2
    Mathematica has a front end, which formats and displays results, and a kernel, which does almost all the computation. The kernel does one calculation at a time. That is why you can do <shift><enter> on two or more expressions on the screen and those will be passed to the kernel to complete when the kernel has finished the previous calculation.

    With version 8 there have been some limited abilities to do parallel calculations
    http://reference.wolfram.com/mathematica/guide/ParallelComputing.html
    but I suspect this may not be what you want done.

    There is one other possible solution. You can purchase a license for additional kernels from Wolfram. Then I believe you can run all the kernels you have license for at the same time. Or you can purchase Premier Support. That should provide you with one additional license and you might be able to run both of those at the same time. I have never tried this so you should make certain this will do what you need before paying your money.

    For your second question, it is true that Mathematica does not remember all the state of a computation. You might look at the documentation for DumpSave and see if that will accomplish what you need.

    You can manually create assignment statements in your notebook. Then the next time you start the notebook you can evaluate those assignment statements to restore the value of variables.

    Mathematica, and almost all other software, forgets all current work, all open windows, all open files, all variable assignments, etc. when you exit and restart, even when you reload a saved file. I wonder if this might be because Windows and window software had a long history of bugs and errors and being unstable and the programmers thought they might make this somewhat less visible and a problem if they did not restore everything after a shut down or restart and made you manually begin again.

    Good mathematics is more important than good English, just as long as we can both understand. Your use of English is almost certainly better than my use of any other human language. For that I am also sorry.
     
  4. Nov 28, 2011 #3
    How about saving the results to a file then just loading it's contents when you start up again?
     
  5. Nov 28, 2011 #4
    Bill Simpson thanks for your comments.

    jackmell i do not know how to do that.

    however i think i should define the results of computation in new variables.
    for example if after a computation i obtain a matrix i define it for another variable.
     
  6. Nov 28, 2011 #5
    Try Put and Get although if it's a lot of data, might be slow:

    mymatrix = {{1, 2}, {3, 4}};
    Put[mymatrix, "myfile.dat"]
    fromfile = Get["myfile.dat"]

    There are also other file operations to use to save and retrieve data. Look into them with the help function.
     
  7. Nov 28, 2011 #6

    phyzguy

    User Avatar
    Science Advisor

    A better solution is to use Save and Get. After doing the heavy calculation, you have the new matrix - suppose it is called M. Use

    Save["MyMatrix.m",M]

    The next time you run the notebook, add:
    Get["MyMatrix.m"]

    The matrix will be loaded without having to recalculate. You can save multiple objects:

    Save["MyStuff.m",{M,N,P,Q,R}]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Running simultaneous computation in mathematica
Loading...