TransWikia.com

Problem with the precision while plotting a figure

Mathematica Asked by sara sam on January 23, 2021

I am trying to plot eigenvalues of a 16×16 matrix.
Below you can see the code. I get some errors like “precision may be lost”, and “Eigenvalues at some positions are expected to be the same”.
As a result, there are some unwanted jumps in the plot (see below). In the correct plot, there should not be any jumps between the positive and negative values of the y-axis (there should be 8 curves that remain in y>0, and 8 in y<0).
Any suggestion of what am I doing wrong?

Thanks in advance.

IM = IdentityMatrix;
TP = Transpose;
KP = KroneckerProduct;
CT = ConjugateTranspose;
MF = MatrixForm;

px = {1, 0, 0}; py = {0, 1, 0}; pz = {0, 0, 1};
[Sigma]x = 1/2 {{0, 1}, {1, 0}};
[Sigma]y = 1/2 {{0, -I}, {I, 0}};
[Sigma]z = 1/2 {{1, 0}, {0, -1}};
gn = [Minus]0.1618;
[Beta]e = 9.27*10^-24; 
[Beta]n = 1/1836 * [Beta]e;

S = KP[KP[px, [Sigma]x], IM[8]] + KP[KP[py, [Sigma]y], IM[8]] + 
   KP[KP[pz, [Sigma]z], IM[8]];
B = KP[KP[{bx, 0, 0}, IM[2]], IM[8]]; 
A = 10^6*KP[
    KP[{{274.3, -202.5, -350.8}, {-202.5, 827.5, 635.2}, {-350.8, 
       635.2, 706.1}}, IM[2]], IM[8]];
Q = 10^6*KP[
    KP[{{10.4, -9.1, -10}, {-9.1, -6, -14.3}, {-10, -14.3, -4.4}}, 
     IM[2]], IM[8]];
g = KP[KP[{{2.90, -2.95, -3.56}, {-2.95, 8.90, 5.57}, {-3.56, 5.57, 
      5.12}}, IM[2]], IM[8]]; 


ix = 1/2 {{0, Sqrt[7], 0, 0, 0, 0, 0, 0}, {Sqrt[7], 0, Sqrt[12], 0, 0,
     0, 0, 0}, {0, Sqrt[12], 0, Sqrt[15], 0, 0, 0, 0}, {0, 0, 
    Sqrt[15], 0, 4, 0, 0, 0}, {0, 0, 0, 4, 0, Sqrt[15], 0, 0}, {0, 0, 
    0, 0, Sqrt[15], 0, Sqrt[12], 0}, {0, 0, 0, 0, 0, Sqrt[12], 0, 
    Sqrt[7]}, {0, 0, 0, 0, 0, 0, Sqrt[7], 0}};
iy = -I/2*{{0, Sqrt[7], 0, 0, 0, 0, 0, 0}, {-Sqrt[7], 0, Sqrt[12], 0, 0, 0,
     0, 0}, {0, -Sqrt[12], 0, Sqrt[15], 0, 0, 0, 0}, {0, 0, -Sqrt[15],
     0, 4, 0, 0, 0}, {0, 0, 0, -4, 0, Sqrt[15], 0, 0}, {0, 0, 0, 
    0, -Sqrt[15], 0, Sqrt[12], 0}, {0, 0, 0, 0, 0, -Sqrt[12], 0, 
    Sqrt[7]}, {0, 0, 0, 0, 0, 0, -Sqrt[7], 0}};
iz = 1/2 {{7, 0, 0, 0, 0, 0, 0, 0}, {0, 5, 0, 0, 0, 0, 0, 0}, {0, 0, 
     3, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 0, -1, 0, 
     0, 0}, {0, 0, 0, 0, 0, -3, 0, 0}, {0, 0, 0, 0, 0, 0, -5, 0}, {0, 
     0, 0, 0, 0, 0, 0, -7}};

it = KP[px, KP[IM[2], ix]] + KP[py, KP[IM[2], iy]] + 
   KP[pz, KP[IM[2], iz]];

(*Main matrix*)

H = CT[it].A.S + 
   CT[it].Q.it + [Beta]e * TP[B].g.S/(2 [Pi]*hbar) - [Beta]n*gn*
    TP[B].it/(2 [Pi]*hbar);

hbar = 1.054*10^-34;

eigenvalues = Eigenvalues[H];

Plot[eigenvalues, {bx, -0.2, 0.2}, Frame -> True, 
 FrameLabel -> {"B", "y"}, WorkingPrecision -> 50]

enter image description here

One Answer

You are running into numerical precision trouble. Use exact numbers instead. With all your definitions, change the calculation of eigenvalues to:

eigenvalues = Eigenvalues[Rationalize[H, 0]]

You can then plot them as you expected, although the following naïve plot is remarkably slow:

Plot[
  Evaluate@N@eigenvalues, {bx, -0.2, 0.2}, 
  Frame -> True, FrameLabel -> {"B", "y"}
]

eigenvalues - no zero crossings

Correct answer by MarcoB on January 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP