# Creat a matrix with boundary condition

I would creat a symmetric matrix, but how can I set the boundary in Subscript?

Array[Subscript[a, #1, #2] &, {3, 3}] // MatrixForm


$a_{ij} = a_{ji}$, $j$ is not equal to $i$.

• Jul 19 '18 at 0:35

Array[Subscript[a, ## & @@ Sort[{##}]] &, {5, 5}] //  MatrixForm // TeXForm


$\left( \begin{array}{ccccc} a_{1,1} & a_{1,2} & a_{1,3} & a_{1,4} & a_{1,5} \\ a_{1,2} & a_{2,2} & a_{2,3} & a_{2,4} & a_{2,5} \\ a_{1,3} & a_{2,3} & a_{3,3} & a_{3,4} & a_{3,5} \\ a_{1,4} & a_{2,4} & a_{3,4} & a_{4,4} & a_{4,5} \\ a_{1,5} & a_{2,5} & a_{3,5} & a_{4,5} & a_{5,5} \\ \end{array} \right)$

You can also use

 Array[Subscript[a, Min @ ##, Max @ ##] &, {5, 5}]

• thanks a lot! how can I get the voigt notation from second order tensor in a efficient way in Mathematica? Jul 19 '18 at 21:19
• @ABCDEMMM, i am afraid i don't know off the top of my head; that sounds like good new question.
– kglr
Jul 19 '18 at 21:25
• I am also afraid that I will I get negative note if i ask such a question.... Jul 19 '18 at 21:27
• @ABCDEMMM, i happen to think that it is a good question. With a small example and a link (say, to wikipedia) it is likely to be received very well on this site.
– kglr
Jul 19 '18 at 21:34