0
$\begingroup$

Mathematica sometimes quits kernel while I'm trying to plot a bunch of eigenvalues of a matrix vs some parameter, accompanied by a beep sound. It didn't used to do this at all, so I don't think its something to do with my code (as clunky as it is), however I will provide the code below.

Any suggestions as to what could be the common causes for this? I'm running Mathematica on a MacBook Pro 2015, 2.7 GHz Intel Core i5 processor & apparently still has 19 GB free of storage.

Here's the full code for completeness:

m = 20;  (* Set matrix size, i.e. Subscript[N, max]= 2m+1*)

(* Matrix to diagonalize *)

mat[a_?NumericQ, b_?NumericQ] := 
  SparseArray[{Band[{1, 1}] -> Table[(i)^2, {i, -m, m}], 
    Band[{2, 1}] -> a, Band[{1, 2}] -> a, Band[{3, 1}] -> b, 
     Band[{1, 3}] -> b}, {2 m + 1, 2 m + 1} ] ; 

(*Ordered eigenvalues *)
eigs[a_, b_] := SortBy[Transpose[Eigensystem[mat[a, b]]], First]

Clear[b];
b = 0.996;

eigsplot = Plot[{
eigs[a, b][[1]][[1]],
eigs[a, b][[2]][[1]],
eigs[a, b][[3]][[1]],
eigs[a, b][[4]][[1]],
eigs[a, b][[5]][[1]],
eigs[a, b][[6]][[1]],
eigs[a, b][[7]][[1]],
eigs[a, b][[8]][[1]],
eigs[a, b][[9]][[1]],
eigs[a, b][[10]][[1]],
eigs[a, b][[11]][[1]],
eigs[a, b][[12]][[1]],
eigs[a, b][[13]][[1]]
}, {a, -26., 26.}, PlotPoints -> 8, MaxRecursion -> 8, 

PlotRange -> {{-26, 26}, {-45, 45}},

Frame -> True,
Axes -> {False, False},

PlotStyle -> {
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black],
 Directive[AbsoluteThickness[1], Black]
 },

TicksStyle -> Directive[AbsoluteThickness[2]],  
FrameStyle -> Directive[AbsoluteThickness[0.8], FontSize -> 20],
AxesStyle -> Directive[AbsoluteThickness[0.8]],

FrameLabel -> {"a", "eigs" },

ImageSize -> 20.6*72/2.54,
ImagePadding -> {{75, 9}, {75, 2}}]; 


Show[eigsplot]
$\endgroup$
  • $\begingroup$ Did you check Help > Why the Beep?... (menu command). It will probably just say the kernel quit unexpectedly. A possible cause is running out of memory (e.g. it requests 20GB -- I doubt you would know you ran out before the request failed). (Why not use Eigenvalues instead of Eigensystem?) $\endgroup$ – Michael E2 Oct 26 '18 at 16:56
  • 1
    $\begingroup$ I take back the out-of-memory assertion -- it used 17MB on my Mac and ran without a hitch. I'm using V11.3. Which version are you using? $\endgroup$ – Michael E2 Oct 26 '18 at 17:04
  • 1
    $\begingroup$ This plots immediately for me in Mathematiica 11.3 on a 2018 MBP running Mojave. No crash. What version of M are you using? $\endgroup$ – user6014 Oct 26 '18 at 17:04
  • $\begingroup$ @MichaelE2 you're right, "Why the beep" says "The kernel Local has quit (exited) during the course of an evaluation". I will certainly use Eigenvalues instead of Eigensystem in the future (I use both eigenvectors and eigenvalues in my actual notebook so use eigensystem and I make the function remember values that it finds). $\endgroup$ – Trock Oct 29 '18 at 12:25
  • $\begingroup$ @user6014 I am using Mathematica 11.3 on an early 2015 MBP. I was using Mathematica 9.something and started having this issue, so I updated to 11.3 but the issue remains. My Mac is running OS X Yosemite version 10.10.5. Although I feel 19 GB is still enough storage - is the fact that I've filled up nearly all of the ~250 GB storage a possible cause? $\endgroup$ – Trock Oct 29 '18 at 12:32

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.