Tag Archives: mathematica

Create a symmetric matrix in Mathematica

Here is a quick way to create a symmetric matrix in Mathematica. The code below creates a generic 6×6 matrix (line 1), then mirrors the above-diagonal elements to their below-diagonal counterparts (substitution in lines 3-5). am = Array[Subscript[a,##] &, {6,6}]; am = am /. Flatten[Table[ Subscript[a,i,j] -> Subscript[a,j,i], {i,2,6}, {j,1,i-1}]]
Posted in Scientific Computing, Tips & Tricks | Tagged | Leave a comment