0
$\begingroup$

This question already has an answer here:

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$

marked as duplicate by Sjoerd C. de Vries, Community Dec 11 '15 at 19:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ You can adapt the solution in this answer to your case; just make sure the random eigenvalues are real. $\endgroup$ – J. M. will be back soon Dec 11 '15 at 19:14
  • $\begingroup$ Alternatively, generate a random matrix $A$ and take $\frac12(A+A^\dagger)$. $\endgroup$ – Rahul Dec 11 '15 at 19:22
  • $\begingroup$ Very helpful thank you guys!!! $\endgroup$ – nekodesu Dec 11 '15 at 19:27
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.