Skip to main content
6 of 6
added 1 character in body
L.K.
  • 693
  • 1
  • 7
  • 17

Speeding and optimizing the Graphics Plot

I am having a Hermitian Matrix(HCF[k]) depending on a parameter $k$.

My job is to plot the Eigenvalues of the matrix as the parameter $k$ is changed.

But I am facing some problems.
(i) My Mathematica file size, which is of around whopping 90Mb, when HCF[k] is around $284\times284$.
(ii) This part of code is very slow as the size of HCF[k] is increasing.

kdel = 0.00001; (* offset *)
kIn = -π - kdel;  (*Initial value of k *)
kFin = π + kdel;  (*Final value of k *)
kInc = 0.001; (*Increment of k*)

eigeng = 
 ParallelTable[Eigenvalues[HCF[k]], {k, kIn, kFin, kInc}];


kList = ParallelTable[k, {k, kIn, kFin, kInc}];


kFList = ParallelTable[kList, {i, Transpose@eigeng}];

dataToPlot = Flatten[{kFList\[Transpose], eigeng}\[Transpose], {{1, 3}, {2}}];

Graphics[{Point[{#1, #2}]} & @@@ dataToPlot, Frame -> True,
...(* for the aesthetic of plot, i.e. axis title, range and bla bla*)]
  • Is there a way the size issue can be overcome?
  • Is there a way the code can be sped up a little bit?(I checked my rest of the code, it is very fast, which I did by breaking and evaluating it into small cells).

Addendum

  • Form of HCF[k], as it is huge I will try to show you how it looks for small size say
    \left( \begin{array}{cccccc} -20 \pi & -\frac{e^{i k}}{2} & 0 & -\frac{1}{2} & 0 & 0 \\ -\frac{1}{2} e^{-i k} & -20 \pi & -\frac{1}{2} & 0 & 0 & 0 \\ 0 & -\frac{1}{2} & 0 & -\frac{e^{i k}}{2} & 0 & -\frac{1}{2} \\ -\frac{1}{2} & 0 & -\frac{1}{2} e^{-i k} & 0 & -\frac{1}{2} & 0 \\ 0 & 0 & 0 & -\frac{1}{2} & 20 \pi & -\frac{e^{i k}}{2} \\ 0 & 0 & -\frac{1}{2} & 0 & -\frac{1}{2} e^{-i k} & 20 \pi \\ \end{array} \right)
L.K.
  • 693
  • 1
  • 7
  • 17