Message Boards Message Boards

0
|
3126 Views
|
15 Replies
|
5 Total Likes
View groups...
Share
Share this post:

HermitianMatrixQ doesn't work for a symbolic matrix

Posted 2 years ago

I'm trying to implement the solution described in 12.4.1 Measurements on a Single Spin of this book:

sJ = (\[HBar]/2) PauliMatrix /@ {1, 2, 3};
normal = {Sin[\[Theta]] Cos[\[Phi]], Sin[\[Theta]] Sin[\[Phi]], 
   Cos[\[Theta]]};
sigmaN = normal . PauliMatrix /@ {1, 2, 3}; 
Eigensystem[sigmaN] // FullSimplify // Transpose // MatrixForm

Then I try to check the Hermitian property of the sigmaN matrix as follows, but all failed:

HermitianMatrixQ[sigmaN]
FullSimplify[
  sigmaN, { \[Theta], \[Phi]  } \[Element] Reals] // HermitianMatrixQ

For more details, please refer to the attachment.

Regards, HZ

Attachments:
POSTED BY: Hongyi Zhao
15 Replies
Posted 2 years ago

Thank you for letting me know the wonderful Wolfram Quantum Framework, but I'd like to start with some low-level understanding of this area in plain Mathematica.

Regards, HZ

POSTED BY: Hongyi Zhao

Have you tried the Wolfram Quantum Framework? http://wolfr.am/wolfram-quantum Also, we recently organized a series of hands-on seminars as part of an online study group. I invite you to access the videos as an introduction to quantum computing using our framework: https://wolfr.am/QC-course

POSTED BY: Mads Bahrami
Posted 2 years ago

@Hans Dolhaine I solved the problem discussed here and describe it as follows:

  1. In order to compare with the results provided by the book, Eigenvectors should be normalized first as follows:

    ev = Normalize /@ Eigenvectors[sigmaN] // 
    FullSimplify[#, {\[Theta] | \[Phi]} \[Element] Reals] &;
    
  2. The results given by the book and the ones generated by Mathematica are, up to a phase factor, identical:

    E^(I \[Phi])
    
  3. I tried different complex conjugate calculate methods discussed here, and they give same results.

  4. HermitianMatrixQ works as follows:

    sigmaN // MatrixForm
    HermitianMatrixQ[sigmaN, 
     SameTest -> (FullSimplify[#1 == #2, {\[Theta] | \[Phi]} \[Element] 
          Reals] &)]
    HermitianMatrixQ[sigmaN, 
     SameTest -> (FullSimplify[#1 - #2 == 
          0, {\[Theta] | \[Phi]} \[Element] Reals] &)]
    
  5. I also asked Jean Dalibard, one of the book's authors, this question.

All relevant calculations and comments mentioned above can be found in the attachments.

Regards, HZ

POSTED BY: Hongyi Zhao

@Gianluca : thanks for these hints

@Honyi Zhao : are you sure everyting is correct in the book? I get different results:

sJ = (\[HBar]/2) PauliMatrix /@ {1, 2, 3};
normal = {Sin[\[Theta]] Cos[\[Phi]], Sin[\[Theta]] Sin[\[Phi]], Cos[\[Theta]]};
(* sigma - matrix *)
sigmaN = normal.PauliMatrix /@ {1, 2, 3};
(* Eigenvectors of sigmaN *)
ev = Eigenvectors[sigmaN] // FullSimplify // Transpose
(* complex-conjugate eigenvectors *)
evc = (ev /. {Complex[0, a_] -> Complex[0, -a]}) // FullSimplify
(* eigenvalues of sigmaN: diagonal elements of diagonalized sigmaN*)
eigvals = Transpose[evc].sigmaN.ev // FullSimplify;
% // MatrixForm
POSTED BY: Hans Dolhaine

Conjugate assumes that \[Theta] is a complex variable. To force \[Theta] to be treated as real you can use ComplexExpand or Simplify:

ComplexExpand[
 Conjugate[Cos[\[Phi]] Sin[\[Theta]] - I Sin[\[Theta]] Sin[\[Phi]]]]
Simplify[
 Conjugate[Cos[\[Phi]] Sin[\[Theta]] - I Sin[\[Theta]] Sin[\[Phi]]], 
 Element[\[Theta], Reals]]
POSTED BY: Gianluca Gorni
Posted 2 years ago

It seems the following also work:

sigmaN // Conjugate // ComplexExpand[#, _ \[Element] Reals] & // 
  FullSimplify // MatrixForm
Sn // Conjugate // ComplexExpand[#, _ \[Element] Reals] & // 
  FullSimplify // MatrixForm

For more details, please refer to the attachment.

See the relevant discussion here.

Attachments:
POSTED BY: Hongyi Zhao

The syntax ComplexExpand[#, _ \[Element] Reals] & does not reflect the documentation. It seems to work, but it is probably equivalent to ComplexExpand alone.

POSTED BY: Gianluca Gorni
Posted 2 years ago

What do you mean by saying "does not reflect the documentation"?

Regards, HZ

POSTED BY: Hongyi Zhao

The second argument of ComplexExpand should be a list of symbols, not a pattern. Also, if the purpose of the pattern Element[_,Reals] was to treat everything as real, then it should apply to I too...

POSTED BY: Gianluca Gorni
Posted 2 years ago

IMO, the pure (or "anonymous") function based method may be more flexible or powerful for more complicated scenarios.

Regards, HZ

POSTED BY: Hongyi Zhao

Concerning HermitianQ:

it seems that Conjugate works somewhat peculiar

sigmaN[[1, 2]]
Conjugate[sigmaN[[1, 2]]]
Conjugate[sigmaN[[1, 2]] /. {Sin[\[Theta]] -> st, Sin[\[Phi]] -> sp, Cos[\[Phi]] -> cp}]
sigmaN[[1, 2]] /. Complex[0, a_] -> Complex[0, -a]
POSTED BY: Hans Dolhaine

I don't know what the expectation value is.

The command Do gives Null as output. To gather the results you must store the in some variable.

POSTED BY: Gianluca Gorni
Posted 2 years ago

Thank you for your explanation. Let's look at another problems:

  1. Why can't I get the expectation value described in 12.4.1.4, i.e., Cos[[Theta]] or -Cos[[Theta]]? enter image description here
  2. Why the Table command works, but the Do command gives nothing?

enter image description here

For more details, please refer to the attachment.

Attachments:
POSTED BY: Hongyi Zhao
Posted 2 years ago

Thank you for your explanation. Let's look at another problem:

Why can't I get the expectation value described in 12.4.1.4, i.e., Cos[[Theta]] or -Cos[[Theta]], as shown in the following screenshot?

enter image description here

For more details, please refer to the attachment.

Attachments:
POSTED BY: Hongyi Zhao

According to the documentation,

HermitianMatrixQ[m] gives True if m is explicitly Hermitian, and False otherwise.

It would seem that it was designed for speed, not for sophistication. It disregards assumptions:

In[26]:= Assuming[Element[\[Theta] | \[Phi], Reals], 
 HermitianMatrixQ[sigmaN]]

Out[26]= False

This is to be expected from functions whose name ends in Q. Compare with IntegerQ:

In[41]:= x = (1 + Sqrt[2])^2 - 2 Sqrt[2];
Expand[x]
IntegerQ[x]

Out[42]= 3

Out[43]= False
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract