0
$\begingroup$

I want to generate random Hermitian matrices. For now, random Hermitian matrices with size 2 are obvious to construct. But elegant methods for higher dimension would be nice! Are there methods besides just randomly generating the upper triangular entires and then conjugating each entries to fill in the lower half? Thanks!!

$\endgroup$
3
  • $\begingroup$ You can adapt the solution in this answer to your case; just make sure the random eigenvalues are real. $\endgroup$ Dec 11, 2015 at 19:14
  • $\begingroup$ Alternatively, generate a random matrix $A$ and take $\frac12(A+A^\dagger)$. $\endgroup$
    – user484
    Dec 11, 2015 at 19:22
  • $\begingroup$ Very helpful thank you guys!!! $\endgroup$
    – nekodesu
    Dec 11, 2015 at 19:27

1 Answer 1

1
$\begingroup$
a = Table[
  Which[x == y, RandomReal[], x < y, RandomComplex[], x > y, 0],
  {x, 5}, {y, 5}]; 

b = Table[
  If[x <= y, a[[x, y]], Conjugate[a[[y, x]] ]], 
  {x, 5}, {y, 5}];

HermitianMatrixQ[b]

(* True *)

Or the simplest (given by Rahul):

1/2 ((a = Table[RandomComplex[], {5}, {5}]) + ConjugateTranspose[a]);

HermitianMatrixQ[%]

(* True *)

$\endgroup$

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