0
$\begingroup$

I've been doing some calcultations on mathematica which involve exponential of matrices. It's well known that if [A,B]=0 then [A,F(B)]=0 where A,B are matrices and [,] is their commutator. Nonetheless, I have a matrix A, which commutes with B and then I know that [A,MatrixExp[B]]=0, but Mathematica gives me a non-zero matrix... I've tried to chop it and it didn't work. So, what could be the source of this error? I checked for the commutator of [A,B] and Mathematica is indeed giving 0. Here is a picture of the matrix plot of the output:

enter image description here

I have a Hamiltonian which is parity invariant and the evolution operator U is not commuting with the parity operator (U=exp(-iHt)) and [Pi,H]=0.

Note: both operators have norm 1.

(Of course, this is just a sanity check of a much bigger calculation that is going wrong, I have a Hamiltonian which is parity invariant and the evolution operator U is not commuting with the parity operator).

Here are the two matrices:

A = SparseArray[{{1,1}->1,{2,33}->1,{3,17}->1,{4,49}->1,{5,9}->1,{6,41}->1,{7,25}->1,{8,57}->1,{9,5}->1,{10,37}->1,{11,21}->1,{12,53}->1,{13,13}->1,{14,45}->1,{15,29}->1,{16,61}->1,{17,3}->1,{18,35}->1,{19,19}->1,{20,51}->1,{21,11}->1,{22,43}->1,{23,27}->1,{24,59}->1,{25,7}->1,{26,39}->1,{27,23}->1,{28,55}->1,{29,15}->1,{30,47}->1,{31,31}->1,{32,63}->1,{33,2}->1,{34,34}->1,{35,18}->1,{36,50}->1,{37,10}->1,{38,42}->1,{39,26}->1,{40,58}->1,{41,6}->1,{42,38}->1,{43,22}->1,{44,54}->1,{45,14}->1,{46,46}->1,{47,30}->1,{48,62}->1,{49,4}->1,{50,36}->1,{51,20}->1,{52,52}->1,{53,12}->1,{54,44}->1,{55,28}->1,{56,60}->1,{57,8}->1,{58,40}->1,{59,24}->1,{60,56}->1,{61,16}->1,{62,48}->1,{63,32}->1,{64,64}->1}];
B = -I*SparseArray[{{1,1}->5,{2,2}->3,{2,3}->2,{3,2}->2,{3,3}->1,{3,5}->2,{4,4}->3,{4,6}->2,{5,3}->2,{5,5}->1,{5,9}->2,{6,4}->2,{6,6}->-1,{6,7}->2,{6,10}->2,{7,6}->2,{7,7}->1,{7,11}->2,{8,8}->3,{8,12}->2,{9,5}->2,{9,9}->1,{9,17}->2,{10,6}->2,{10,10}->-1,{10,11}->2,{10,18}->2,{11,7}->2,{11,10}->2,{11,11}->-3,{11,13}->2,{11,19}->2,{12,8}->2,{12,12}->-1,{12,14}->2,{12,20}->2,{13,11}->2,{13,13}->1,{13,21}->2,{14,12}->2,{14,14}->-1,{14,15}->2,{14,22}->2,{15,14}->2,{15,15}->1,{15,23}->2,{16,16}->3,{16,24}->2,{17,9}->2,{17,17}->1,{17,33}->2,{18,10}->2,{18,18}->-1,{18,19}->2,{18,34}->2,{19,11}->2,{19,18}->2,{19,19}->-3,{19,21}->2,{19,35}->2,{20,12}->2,{20,20}->-1,{20,22}->2,{20,36}->2,{21,13}->2,{21,19}->2,{21,21}->-3,{21,25}->2,{21,37}->2,{22,14}->2,{22,20}->2,{22,22}->-5,{22,23}->2,{22,26}->2,{22,38}->2,{23,15}->2,{23,22}->2,{23,23}->-3,{23,27}->2,{23,39}->2,{24,16}->2,{24,24}->-1,{24,28}->2,{24,40}->2,{25,21}->2,{25,25}->1,{25,41}->2,{26,22}->2,{26,26}->-1,{26,27}->2,{26,42}->2,{27,23}->2,{27,26}->2,{27,27}->-3,{27,29}->2,{27,43}->2,{28,24}->2,{28,28}->-1,{28,30}->2,{28,44}->2,{29,27}->2,{29,29}->1,{29,45}->2,{30,28}->2,{30,30}->-1,{30,31}->2,{30,46}->2,{31,30}->2,{31,31}->1,{31,47}->2,{32,32}->3,{32,48}->2,{33,17}->2,{33,33}->3,{34,18}->2,{34,34}->1,{34,35}->2,{35,19}->2,{35,34}->2,{35,35}->-1,{35,37}->2,{36,20}->2,{36,36}->1,{36,38}->2,{37,21}->2,{37,35}->2,{37,37}->-1,{37,41}->2,{38,22}->2,{38,36}->2,{38,38}->-3,{38,39}->2,{38,42}->2,{39,23}->2,{39,38}->2,{39,39}->-1,{39,43}->2,{40,24}->2,{40,40}->1,{40,44}->2,{41,25}->2,{41,37}->2,{41,41}->-1,{41,49}->2,{42,26}->2,{42,38}->2,{42,42}->-3,{42,43}->2,{42,50}->2,{43,27}->2,{43,39}->2,{43,42}->2,{43,43}->-5,{43,45}->2,{43,51}->2,{44,28}->2,{44,40}->2,{44,44}->-3,{44,46}->2,{44,52}->2,{45,29}->2,{45,43}->2,{45,45}->-1,{45,53}->2,{46,30}->2,{46,44}->2,{46,46}->-3,{46,47}->2,{46,54}->2,{47,31}->2,{47,46}->2,{47,47}->-1,{47,55}->2,{48,32}->2,{48,48}->1,{48,56}->2,{49,41}->2,{49,49}->3,{50,42}->2,{50,50}->1,{50,51}->2,{51,43}->2,{51,50}->2,{51,51}->-1,{51,53}->2,{52,44}->2,{52,52}->1,{52,54}->2,{53,45}->2,{53,51}->2,{53,53}->-1,{53,57}->2,{54,46}->2,{54,52}->2,{54,54}->-3,{54,55}->2,{54,58}->2,{55,47}->2,{55,54}->2,{55,55}->-1,{55,59}->2,{56,48}->2,{56,56}->1,{56,60}->2,{57,53}->2,{57,57}->3,{58,54}->2,{58,58}->1,{58,59}->2,{59,55}->2,{59,58}->2,{59,59}->-1,{59,61}->2,{60,56}->2,{60,60}->1,{60,62}->2,{61,59}->2,{61,61}->3,{62,60}->2,{62,62}->1,{62,63}->2,{63,62}->2,{63,63}->3,{64,64}->5}]/10;
$\endgroup$
18
  • 4
    $\begingroup$ I tell from the color bar that the plotted matrix is indistinguishable from the zero matrix in machine precision. $\endgroup$ Commented Apr 8, 2019 at 18:53
  • 1
    $\begingroup$ Again, can you please note the norm of the commutator? $\endgroup$
    – Roman
    Commented Apr 8, 2019 at 18:54
  • 3
    $\begingroup$ This means your numerical scheme is unstable. Look for a better (stable) propagation scheme, they exist. $\endgroup$
    – Roman
    Commented Apr 8, 2019 at 18:59
  • 1
    $\begingroup$ @MarceloBroinizi Then paste them in a pastebin. 2^8 = 256; that's hardly a big matrix by any measure. $\endgroup$
    – MarcoB
    Commented Apr 9, 2019 at 3:10
  • 1
    $\begingroup$ I managed to paste em in Wolfram cloud! $\endgroup$
    – Janov
    Commented Apr 9, 2019 at 10:12

1 Answer 1

0
$\begingroup$

I cannot reproduce this problem. Defining the exact matrices from your upload (only removing the imaginary unit)

A = SparseArray[{{1,1}->1,{2,33}->1,{3,17}->1,{4,49}->1,{5,9}->1,{6,41}->1,{7,25}->1,{8,57}->1,{9,5}->1,{10,37}->1,{11,21}->1,{12,53}->1,{13,13}->1,{14,45}->1,{15,29}->1,{16,61}->1,{17,3}->1,{18,35}->1,{19,19}->1,{20,51}->1,{21,11}->1,{22,43}->1,{23,27}->1,{24,59}->1,{25,7}->1,{26,39}->1,{27,23}->1,{28,55}->1,{29,15}->1,{30,47}->1,{31,31}->1,{32,63}->1,{33,2}->1,{34,34}->1,{35,18}->1,{36,50}->1,{37,10}->1,{38,42}->1,{39,26}->1,{40,58}->1,{41,6}->1,{42,38}->1,{43,22}->1,{44,54}->1,{45,14}->1,{46,46}->1,{47,30}->1,{48,62}->1,{49,4}->1,{50,36}->1,{51,20}->1,{52,52}->1,{53,12}->1,{54,44}->1,{55,28}->1,{56,60}->1,{57,8}->1,{58,40}->1,{59,24}->1,{60,56}->1,{61,16}->1,{62,48}->1,{63,32}->1,{64,64}->1}];
B = SparseArray[{{1,1}->5,{2,2}->3,{2,3}->2,{3,2}->2,{3,3}->1,{3,5}->2,{4,4}->3,{4,6}->2,{5,3}->2,{5,5}->1,{5,9}->2,{6,4}->2,{6,6}->-1,{6,7}->2,{6,10}->2,{7,6}->2,{7,7}->1,{7,11}->2,{8,8}->3,{8,12}->2,{9,5}->2,{9,9}->1,{9,17}->2,{10,6}->2,{10,10}->-1,{10,11}->2,{10,18}->2,{11,7}->2,{11,10}->2,{11,11}->-3,{11,13}->2,{11,19}->2,{12,8}->2,{12,12}->-1,{12,14}->2,{12,20}->2,{13,11}->2,{13,13}->1,{13,21}->2,{14,12}->2,{14,14}->-1,{14,15}->2,{14,22}->2,{15,14}->2,{15,15}->1,{15,23}->2,{16,16}->3,{16,24}->2,{17,9}->2,{17,17}->1,{17,33}->2,{18,10}->2,{18,18}->-1,{18,19}->2,{18,34}->2,{19,11}->2,{19,18}->2,{19,19}->-3,{19,21}->2,{19,35}->2,{20,12}->2,{20,20}->-1,{20,22}->2,{20,36}->2,{21,13}->2,{21,19}->2,{21,21}->-3,{21,25}->2,{21,37}->2,{22,14}->2,{22,20}->2,{22,22}->-5,{22,23}->2,{22,26}->2,{22,38}->2,{23,15}->2,{23,22}->2,{23,23}->-3,{23,27}->2,{23,39}->2,{24,16}->2,{24,24}->-1,{24,28}->2,{24,40}->2,{25,21}->2,{25,25}->1,{25,41}->2,{26,22}->2,{26,26}->-1,{26,27}->2,{26,42}->2,{27,23}->2,{27,26}->2,{27,27}->-3,{27,29}->2,{27,43}->2,{28,24}->2,{28,28}->-1,{28,30}->2,{28,44}->2,{29,27}->2,{29,29}->1,{29,45}->2,{30,28}->2,{30,30}->-1,{30,31}->2,{30,46}->2,{31,30}->2,{31,31}->1,{31,47}->2,{32,32}->3,{32,48}->2,{33,17}->2,{33,33}->3,{34,18}->2,{34,34}->1,{34,35}->2,{35,19}->2,{35,34}->2,{35,35}->-1,{35,37}->2,{36,20}->2,{36,36}->1,{36,38}->2,{37,21}->2,{37,35}->2,{37,37}->-1,{37,41}->2,{38,22}->2,{38,36}->2,{38,38}->-3,{38,39}->2,{38,42}->2,{39,23}->2,{39,38}->2,{39,39}->-1,{39,43}->2,{40,24}->2,{40,40}->1,{40,44}->2,{41,25}->2,{41,37}->2,{41,41}->-1,{41,49}->2,{42,26}->2,{42,38}->2,{42,42}->-3,{42,43}->2,{42,50}->2,{43,27}->2,{43,39}->2,{43,42}->2,{43,43}->-5,{43,45}->2,{43,51}->2,{44,28}->2,{44,40}->2,{44,44}->-3,{44,46}->2,{44,52}->2,{45,29}->2,{45,43}->2,{45,45}->-1,{45,53}->2,{46,30}->2,{46,44}->2,{46,46}->-3,{46,47}->2,{46,54}->2,{47,31}->2,{47,46}->2,{47,47}->-1,{47,55}->2,{48,32}->2,{48,48}->1,{48,56}->2,{49,41}->2,{49,49}->3,{50,42}->2,{50,50}->1,{50,51}->2,{51,43}->2,{51,50}->2,{51,51}->-1,{51,53}->2,{52,44}->2,{52,52}->1,{52,54}->2,{53,45}->2,{53,51}->2,{53,53}->-1,{53,57}->2,{54,46}->2,{54,52}->2,{54,54}->-3,{54,55}->2,{54,58}->2,{55,47}->2,{55,54}->2,{55,55}->-1,{55,59}->2,{56,48}->2,{56,56}->1,{56,60}->2,{57,53}->2,{57,57}->3,{58,54}->2,{58,58}->1,{58,59}->2,{59,55}->2,{59,58}->2,{59,59}->-1,{59,61}->2,{60,56}->2,{60,60}->1,{60,62}->2,{61,59}->2,{61,61}->3,{62,60}->2,{62,62}->1,{62,63}->2,{63,62}->2,{63,63}->3,{64,64}->5}]/10;

we see that the commutator vanishes exactly,

A.B - B.A // Norm

0

With the numerical matrix exponential

U = MatrixExp[-I*B // N];

the commutator vanishes to numerical precision,

A.U - U.A // Norm

8.32424*10^-16

and even multiplying U a million times with itself (to simulate your propagation) still commutes with A pretty well:

F = Nest[U.# &, IdentityMatrix[Dimensions[U]], 10^6];
A.F - F.A // Norm

4.40179*10^-13

I suspect there's some other bug in your code.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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