I have a command of the form J[b,c,n] which outputs a list of complex numbers, obtained by using FindRoot. Some outputs take over 4 hours to compute and once computed I would like to be able to save the values obtained so if I switch computers or open a new notebook I can get the values without spending time computing again. I would also like, as I compute the function for different parameters, this file of outputs to automatically update, so it really is producing a library of saved outputs. This could then be distributed with the relevant notebook of code so other people using it can save time if they want to compute something previously computed.

I am aware of questions regarding DumpSave and ways to save outputs but I'm not sure if it can be used in the way I would like. Any pointers would be appreciated.

  • 1
    $\begingroup$ In such cases, I usually do the following.1. Copy-paste the obtained list to a separate cell and give this list a name. That is, in front of the list I put myList= and after the list put ;. Further, I put this cell at the end of the notebook in which I work with this list, and in a separate Section, and transform the cell into the InitializationCell. Then I collapse the corresponding Section around its name. Done. Prior to beginning working with it I evaluate the Initialisation Cells. $\endgroup$ Jan 14, 2021 at 11:03
  • $\begingroup$ My problem with this approach is that usually I apply the function to a list of parameters, say 100 parameter values, so doing this by hand for each list (which contains around 1 million entries, is not very efficient. Also, I'm not sure how the function would behave if I saved the output of, say, J[0,0,2] with the name J[0,0,2]. $\endgroup$
    – math
    Jan 14, 2021 at 11:14
  • 1
    $\begingroup$ You could make a list containing 100 parameter values and apply your function to this list as the whole yielding a nested list with results. You save it separately and address sublists when needed. Further, there is no problem with assigning such as J[0, 0, 2] = {1, 2, 3}; J[2, 0, 0] = {3, 2, 1};'. Just try. Finally, I propose that for the purpose of the example you invent a function J[b,c,n] much simpler than your real one, but showing features important for your question, and a list of 3 values of parameters. With such an example we will be able to help you better. $\endgroup$ Jan 14, 2021 at 11:48
  • 1
    $\begingroup$ Continuation. The lists I work with are also of comparable size, but the saving-retrieving method I described works. $\endgroup$ Jan 14, 2021 at 11:50


Browse other questions tagged or ask your own question.