I am trying to select a matrix element using Part or [[ ]] but somehow it doesn't work.
d = MatrixForm[
Table[If[k == n,
0, ((k*n)/(k^2 - n^2))*Exp[I*Pi^2*(k^2 - n^2)*f]], {k, 4},
{n, 4}]]
d[[1, 2]]
Output:
{(2/3)*E^(3*I*f*Pi^2), 0, -(6/5)/E^(5*I*f*Pi^2), -(2/3)/
E^(12*I*f*Pi^2)}
What shows up is the 2nd row instead. I tried copying the output of d in matrix form and writing [[1,2]] following it and it did work, outputting the element of the first row and second collumn.
MatrixForm[{{0, -(2/(3*E^(3*I*f*Pi^2))), -(3/(8*E^(8*I*f*Pi^2))),
-(4/(15*E^(15*I*f*Pi^2)))}, {(2/3)*E^(3*I*f*Pi^2), 0,
-(6/(5*E^(5*I*f*Pi^2))), -(2/(3*E^(12*I*f*Pi^2)))},
{(3/8)*E^(8*I*f*Pi^2), (6/5)*E^(5*I*f*Pi^2),
0, -(12/(7*E^(7*I*f*Pi^2)))},
{(4/15)*E^(15*I*f*Pi^2), (2/3)*E^(12*I*f*Pi^2), (12/7)*
E^(7*I*f*Pi^2), 0}}] [[1, 2]]
Output:-(2/3) E^(-3 I f \[Pi]^2)
But I don't understand why d[[1,2]] doesn't work.
If[k == n, 0, ((k*n)/(k^2 - n^2))*Exp[I*Pi^2*(k^2 - n^2)*f]], {k, 4}, {n, 4}]) // MatrixForm d[[1, 2]]``` : The reason is that MatrixForm output have Head equal to MatrixForm. These are not lists any more, so the `Part` does not work.– Syed Oct 02 '21 at 15:26MatrixForm(like other*Formfunctions) is for formatting only! It doesn't turn something into a matrix. a list of equal-length lists is, by itself, already considered a matrix in mathematica. – thorimur Oct 03 '21 at 00:14//MatrixForm– ForacleFunacle Oct 03 '21 at 15:33