2
$\begingroup$

My Mathematica 13.1 crashes when I try to see the result of 'Save' for some very long expressions, and produces short DumpSave files which when clicked on contain only Null.

I have a system

    L = \[Lambda] - mx  x; fz = y (bc/(kb + y) - dc/(kd + y)) - mz;
    x1 = L -   \[Beta] x v ;
    y1 = \[Beta] x v  - byz y z - my  y;
    v1 = B my y - \[Beta] x v - bvz  v z - mv  v;
    z1 = z fz;
    dyn = {x1, y1, v1, z1}; X = {x, y, v, z};
    cfp = Solve[Thread[dyn == 0], X]
    Length[cfp]
    cfp[[1]]
cfp[[2]]

This takes a little while to solve on Mathematica and yields 6 answers, the first and second ones being very simple, the others not. The results take 20.6 MB. I tried saving the result in two ways

Save["cfp.m", cfp]
DumpSave["cfp.mx", cfp]

''Save'' produces a file of 2852 Ko; trying to open it by clicking on it crashes the file which produced the expression.
''DumpSave'' produces a file of 38 Ko containing only the word Null.

Thanks for all the answers, I haven't tried them yet, it seemed that first priority was to give the full example. It is worrisome that DumpSave works on other computers, but not on mine

$\endgroup$
6
  • 3
    $\begingroup$ did you try DumpSave? see how-do-i-save-a-variable-or-function-definition-to-a-file $\endgroup$
    – Nasser
    May 18 at 6:21
  • $\begingroup$ Similar results. For the long expression a 1Ko file (probably empty file) was created. For the shorter, a 58Ko file was created. It contained only the word Null. I guess there are some limits to what can be saved under my Mathematica Setup $\endgroup$
    – florin
    May 18 at 6:56
  • 2
    $\begingroup$ Nasser is right to say that you should be using something like DumpSave["filename.mx", expression], that works. You say that doesn't work for you, i.e something that does works for other people doesn't work for you. That hints there is a problem in the way you are implementing the solution. We can only speculate, unless you provide a minimum working example of your problem. Please edit your question and provide a minimal well-formatted Mathematica code example of how you are saving your data. $\endgroup$
    – rhermans
    May 18 at 7:27
  • 4
    $\begingroup$ If your file is empty, is possible you are doing something like DumpSave["filename.mx", expression;] (notice the extra ;). Is that the case? $\endgroup$
    – rhermans
    May 18 at 7:28
  • 2
    $\begingroup$ I have run your code, and DumpSave["cfp.mx", cfp] does produce a 33.8KB file with the correct data. It's not empty. It starts with "(*This is a Wolfram Language binary dump file. It can be loaded with Get.*)" then it becomes binary. $\endgroup$
    – rhermans
    May 18 at 9:51

1 Answer 1

-1
$\begingroup$

Try

book= ToString[expression]; Export[Environment["userprofile"]<>"\Desktop\book.txt",book]

and open it in WordPad.

Its not even difficult to StringReplace the commas or other special strings like " "x__~~":=" -> Newline<>x<>":=" in order to insert line breaks. Can be done in the Export command.

$\endgroup$
9
  • $\begingroup$ How do you know ToString and "Text" format is relevant here? I fail to see how this answer is relevant. Export if for changing format, which was not mentioned by the OP. $\endgroup$
    – rhermans
    May 18 at 7:51
  • $\begingroup$ Its the lasr possibility remainig, to check an expression by eye, that not is triggering Mathematica to look at the content. If ToString crashes, there will be a very serious problem in the system. Export of Mathemarica formats does some interpreting. In vs 13 Windows is crashing for me on numerous tasks, even a search for a .nb in Windows explorer. $\endgroup$
    – Roland F
    May 18 at 8:05
  • $\begingroup$ In that case, Is this is more like a comment than an answer? You don't say that your is a strategy to troubleshoot. It reads like an answer that missed the point. Probably you could edit it to improve it. $\endgroup$
    – rhermans
    May 18 at 8:06
  • 1
    $\begingroup$ No, you are missing the point. Import and Export as plain text is always the sure way. Like the context menu by mouse right click and choice 'SaveAs' as the last exit before you have to kill the kernel. $\endgroup$
    – Roland F
    May 18 at 9:28
  • 1
    $\begingroup$ @rhermans Cue "while I agree this response could stand some improvement..." $\endgroup$ May 18 at 22:55

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.