Message Boards Message Boards

0
|
7380 Views
|
8 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to save output of commands like Solve

Posted 9 years ago

Hello,

I have a notebook which at the end produces an output of 'Solve' command. Now this output is huge and takes enormous time to be calculated. Thus I need to save this output in a file for subsequent uses without running the whole notebook again and again. May I ask you for a recommendation. Just be aware, that since this is not a definition, I can not use 'Dumpsave' or 'Put'.

Thanks.

8 Replies
Posted 9 years ago

You can try AppendTo[]

AppendTo[SaveSolution,Solution]

Each time you run your model, your final result will be save in SaveSolution in a list.

POSTED BY: Thai Kee Gan

Yes, I have tried it.

In[188]:= solution = Solve[x^2 == 1, x];
          Save["solution.m", solution];
          Clear[solution];
          Get["solution.m"]

Out[191]= {{x -> -1}, {x -> 1}}
POSTED BY: Ilian Gachevski

Thanks Llian, but have you actually tried it before, for it does not work, and the error is:

"solution must be a symbol, a string, or a list of symbols and strings"

Could you please verify this?

 solution = Solve[...];
 Save["solution.m", solution];
POSTED BY: Ilian Gachevski

Dear Mr. Cleary,

Thanks for your response, but may had noticed, I noted that the 'Put' command is not a solution for this problem, since output of 'Solve' is not a symbol, nor a definition. It is a list which makes for this somehow. Hence this is not a solution.

Thanks.

Posted 9 years ago

Maybe this is what you are looking for, take a look at this command and see if you can adapt it.

PutAppend (>>>)

Paul.

POSTED BY: Paul Cleary

A semicolon (;) after a command will perform the operation and store the result without showing the output.

POSTED BY: S M Blinder

Dear Mr. Blinder

I believe I did not make myself clear. What I intend to do is to save the output of Solve in a file, so that I could read it from the file instead of running the 'Solve' command again. I believe I am correct if I say after the kernel is shut down, all the data is lost, SO a simple semicolon would not do any good! Semicolon is a totally different command, as you have put it correctly.

Thanks.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract