3

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$.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
ABCDEMMM
  • 1,816
  • 1
  • 9
  • 17
  • may be https://mathematica.stackexchange.com/questions/7887/best-way-to-create-symmetric-matrices – Nasser Jul 19 '18 at 00:35

1 Answers1

4
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}]
kglr
  • 394,356
  • 18
  • 477
  • 896
  • thanks a lot! how can I get the voigt notation from second order tensor in a efficient way in Mathematica? – ABCDEMMM 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.... – ABCDEMMM 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