1
$\begingroup$

Running the following code takes about 30 min on my laptop (everything before the Reduce is instant) and produces a Large output that Mathematica does not display, only shows buttons Show more, Show less, Show all, Set size limit. Clicking any of these buttons freezes Mathematica and for a while the rest of the computer as well. A dialog with Force quit, Wait appears in Mathematica, but is also unresponsive.

When I got it to display, even selecting that cell caused a 10 second slowdown and closing the cell about 1 minute, with Force quit/ Wait messages. The output did not print to file using the OpenAppend suggestion from this question.

How to see more output without crashing Mathematica? I currently don't have an alternate computer to try this on.

Using version 11.3, Processor : Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz Memory : 16318MB (3910MB used) Machine Type : Laptop Operating System : Ubuntu 18.04.4 LTS

Clear[pi1, pi2, foc1, foc2, d, vs, d1, d2, p1, p2, q, c, hess, dpdq, \
dfocdq, dpdqsub, dDvs, dDp1, ddDvs, ddDp1, foc1sub, foc2sub, Dvs, \
Dp1, soc1sub, soc2sub]
$Assumptions = 
  0 < p1 < p2 < q && q > 1 && 0 < c < p2 && 
   Flatten@Thread[0 < {d, pi1, pi2}];
vs = (p2 - p1)/(q - 1);
d1 = d[p1] - d[vs];
d2 = d[vs];
foc1 = D[p1*d1, p1];
foc2 = D[(p2 - c)*d2, p2];
hess = D[{foc1, foc2}, {{p1, p2}}];
dfocdq = {{D[foc1, q]}, {D[foc2, q]}};
dpdq = -Inverse[hess].dfocdq;
dpdqsub = 
  dpdq /. {Derivative[1][d][(-p1 + p2)/(-1 + q)] -> dDvs, 
    Derivative[1][d][p1] -> 
     dDp1, (d^\[Prime]\[Prime])[(-p1 + p2)/(-1 + q)] -> 
     ddDvs, (d^\[Prime]\[Prime])[p1] -> ddDp1};
soc1sub = 
  hess[[1, 1]] /. {Derivative[1][d][(-p1 + p2)/(-1 + q)] -> dDvs, 
    Derivative[1][d][p1] -> 
     dDp1, (d^\[Prime]\[Prime])[(-p1 + p2)/(-1 + q)] -> 
     ddDvs, (d^\[Prime]\[Prime])[p1] -> ddDp1};
soc2sub = 
  hess[[2, 2]] /. {Derivative[1][d][(-p1 + p2)/(-1 + q)] -> dDvs, 
    Derivative[1][d][p1] -> 
     dDp1, (d^\[Prime]\[Prime])[(-p1 + p2)/(-1 + q)] -> 
     ddDvs, (d^\[Prime]\[Prime])[p1] -> ddDp1};
foc1sub = 
  foc1 /. {Derivative[1][d][(-p1 + p2)/(-1 + q)] -> dDvs, 
    Derivative[1][d][p1] -> dDp1, d[(-p1 + p2)/(-1 + q)] -> Dvs, 
    d[p1] -> Dp1};
foc2sub = 
  foc2 /. {Derivative[1][d][(-p1 + p2)/(-1 + q)] -> dDvs, 
    Derivative[1][d][p1] -> dDp1, d[(-p1 + p2)/(-1 + q)] -> Dvs, 
    d[p1] -> Dp1};
Reduce[
 dpdqsub[[2, 1]] < 0 && dDp1 < 0 && dDvs < 0 && 
  ddDp1 \[Element] Reals && ddDvs \[Element] Reals && 
  0 < p1 < p2 < q && q > 1 && 0 < c < p2 && foc1sub == 0 && 
  foc2sub == 0 && 0 < Dvs < Dp1 && soc1sub < 0 && soc2sub < 0]
$\endgroup$
4
  • 3
    $\begingroup$ It might be useful to check LeafCount and ByteCount of the expression. If it is particularly huge, maybe saving to a file in InputForm and opening in a text editor would be better. The formatting code can require considerable time and memory for large expressions. $\endgroup$ – Daniel Lichtblau Apr 13 '20 at 15:43
  • $\begingroup$ Not much I can do with the file, even opening it freezes Mathematica. The size of the notebook was 448 MB. After deleting the offending output, 7 MB. $\endgroup$ – Sander Heinsalu Apr 13 '20 at 18:22
  • $\begingroup$ The FE is an unreliable POS. Try not to visualize anything with it. Only try to show something if you can be absolutely certain it won't crash Mathematica. If you use Mathematica as a legitimate tool, not a toy, this becomes something you always have to keep in mind. $\endgroup$ – b3m2a1 Apr 14 '20 at 7:49
  • $\begingroup$ @b3m2a1 What is FE and POS? I am unfamiliar with these acronyms. $\endgroup$ – Sander Heinsalu Apr 17 '20 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.