# Generate random Hermitian matrices [duplicate]

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!!

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

## 1 Answer

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 *)