1

I am dealing with a problem that requires the use of both FindInstance and FindRoot nested in a non-trivial way. The result is dependent on some parameter value $t \in [0,1)$, therefore I use

sol[t_]:=FindRoot[...]

For each t, the calculation of the result takes about 2 minutes (for some values of t it's faster, for others slower), resulting in

Plot[sol[t], {t,0,1}]

to take several hours. As I want to do further calculations/plots with $sol$, I learned from a previous question that i can "save" the results obtained by using

sol[t_]:=sol[t]=FindRoot[...]

However, this still requires me to redo the calculations every time I start Mathematica or the kernel dies for some unexpected reason.

Is there a way to save/export the results obtained "within" $sol$, such that I can "load" them at the beginning of a session? (I apologize for the vague terms, please let me know if I need to clearify my question).

Mitch D
  • 33
  • 3
  • Have a look at DumpSave. – b.gates.you.know.what Feb 18 '13 at 08:40
  • Related: http://mathematica.stackexchange.com/q/1959/131 and http://mathematica.stackexchange.com/q/5450/131 – Yves Klett Feb 18 '13 at 08:41
  • Thanks to you both, that's exactly what I was looking for. I guess I should have found this myself, but I was apparently not looking with the right search phrase. – Mitch D Feb 18 '13 at 08:58
  • You are welcome. If your question is not found to be a duplicate, it will be useful if you write an answer yourself once you have found the right solution to help others benefit from your insights. – Yves Klett Feb 18 '13 at 09:01
  • Changing your user name to something more individual should also help the overall look of the site and facilitate interaction. – Yves Klett Feb 18 '13 at 09:03
  • Thanks for the advice Yves, I will do so, as soon as the 8 hour restriction allows me to. – Mitch D Feb 18 '13 at 09:30

1 Answers1

1

As b.gatessucks and Yves Klett pointed out, 'DumpSave' is the solution. Taking what was written at How do I save a variable or function definition to a file? one can use

DumpSave["~/Desktop/solt.mx", sol]

to save and

DumpGet["~/Desktop/solt.mx"]

to load the results that where calculated while plotting the function $sol$.

Furthermore, as described at How to save all data in all variables so that loading it is fast? (and also the Documentation of DumpSave), by using

DumpSave["~/Desktop/dumpall.mx", "Global`"]

the results and definitions of all symbols/functions are saved and can later be loaded using DumpGet.

Mitch D
  • 33
  • 3