As part of trying to figure out the benefit of the new VectorSymbol, MatrixSymbol, etc. I refreshed myself on the inner workings of the fundamentals. Here, for comment, is my notebook for beginners

How matrices are presented in a notebook

Wolfram, in an effort to please everyone (no one?), sort of ignores the difference between columns and rows, instead using lists and lists of lists and lists of lists of lists etc. To Mathematica, every list is a vector and every vector is a list, no matter if they are shown horizontal or vertical.
​
Here is a typical 3x3 matrix. This is a list of three lists, each having three elements separated by commas.
In[]:=
Remove["Global`*"]//Quiet(*removeallvariables*)
In[]:=
transitionMatrix={{0.8,0.1,0.1},{0.2,0.7,0.1},{0.1,0.3,0.6}}
Out[]=
{{0.8,0.1,0.1},{0.2,0.7,0.1},{0.1,0.3,0.6}}
To be general, we can name the elements in a matrix with symbols having subscripted indices representing their row, column position. Note in each list the first index number is the row. So, in a sense, Mathematica reveals that its usual arrangement of a matrix is by row order, here {Row1, Row2, Row3}.
In[]:=
matA=Array[Subscript[n,##]&,{3,3}]
Out[]=
{{
n
1,1
,
n
1,2
,
n
1,3
},{
n
2,1
,
n
2,2
,
n
2,3
},{
n
3,1
,
n
3,2
,
n
3,3
}}
We can illustrate, using a rule, how real numbers are substituted for their symbolic equivalent, but we still have a list of lists
In[]:=
matA1=MapThread[(#1->#2)&,{matA,transitionMatrix},2]
Out[]=
{{
n
1,1
0.8,
n
1,2
0.1,
n
1,3
0.1},{
n
2,1
0.2,
n
2,2
0.7,
n
2,3
0.1},{
n
3,1
0.1,
n
3,2
0.3,
n
3,3
0.6}}
We can make our matrix look more presentable by using MatrixForm (note the introduction of parenthesis bracketing the entire matrix)...
In[]:=
formMatA=MatrixForm[transitionMatrix]
Out[]//MatrixForm=
0.8
0.1
0.1
0.2
0.7
0.1
0.1
0.3
0.6
... but that creates problems. Look with happens when I multiply (this is NOT the dot product!) the MatrixForm version of my transitionMatrix by a vector. It performs the operation on the entire matrix as a unit rather than on each individual row as we might prefer. Below, Mathematica multiplies the formatted object, the entire matrix as a whole, first by 1, then by 0, then again by 1 to get a new list of three elements.
In[]:=
formMatA*{1,0,1}
Out[]=

0.8
0.1
0.1
0.2
0.7
0.1
0.1
0.3
0.6
,0,
0.8
0.1
0.1
0.2
0.7
0.1
0.1
0.3
0.6

On the other hand, without the MatrixForm wrapper, we get the matrix multiplication we seek as each row is multiplied by the appropriate element of the vector
In[]:=
transitionMatrix*{1,0,1}​​%//MatrixForm
Out[]=
{{0.8,0.1,0.1},{0.,0.,0.},{0.1,0.3,0.6}}
Out[]//MatrixForm=
0.8
0.1
0.1
0.
0.
0.
0.1
0.3
0.6
Using $Post, we can instruct Mathematica to display all matrices in the notebook in MatrixForm
In[]:=
$Post:=If[MatrixQ[#1],MatrixForm[#1],#1]&(*outputsallmatricesinMatrixForm*)
Now we do not have to wrap in MatrixForm to get the matrix appearance. Again, note the parenthesis for matrix form.
In[]:=
transitionMatrix
Out[]//MatrixForm=
0.8
0.1
0.1
0.2
0.7
0.1
0.1
0.3
0.6
In[]:=
matA1
Out[]//MatrixForm=
n
1,1
0.8
n
1,2
0.1
n
1,3
0.1
n
2,1
0.2
n
2,2
0.7
n
2,3
0.1
n
3,1
0.1
n
3,2
0.3
n
3,3
0.6
The $Post instruction keeps the expression as a list of lists in the kernel so that operations upon it are not affected by the output form.
In[]:=
transitionMatrix*{1,0,1}
Out[]//MatrixForm=
0.8
0.1
0.1
0.
0.
0.
0.1
0.3
0.6
We can always look at our expression in List form, essentially removing the formatting of $Post, with postfix List. However, this adds another level which must be discarded before operations on rows may take place. Note the addition of Part [[ ]] in the second line below.
In[]:=
transitionMatrix//List​​%[[1]]*{1,0,1}​​TrueQ[%==transitionMatrix*{1,0,1}]
Out[]=
{{{0.8,0.1,0.1},{0.2,0.7,0.1},{0.1,0.3,0.6}}}
Out[]//MatrixForm=
0.8
0.1
0.1
0.
0.
0.
0.1
0.3
0.6
Out[]=
True
What should be remembered is that the Head of the two expressions are not the same
In[]:=
Head[transitionMatrix]
Out[]=
List
In[]:=
Head[formMatA]
Out[]=
MatrixForm

The language of mathematicians and engineers

By convention, mathematicians and engineers use the “matrix on the left” method which works with the matrix in its usual form
In[]:=
transitionMatrix
Out[]//MatrixForm=
0.8
0.1
0.1
0.2
0.7
0.1
0.1
0.3
0.6
The dot product is, therefore:
In[]:=
matEng=transitionMatrix.{1,0,1}
Out[]=
{0.9,0.3,0.7}
Look very carefully at the expressions immediately above and below this line of text. Superficially, they appear the same. But close inspection shows the one below is in parenthesis ( ), not curly braces { }. The one below also lacks commas. These differences indicate MatrixForm. This is a one row matrix. Note the transition matrix itself in MatrixForm, has no commas. Now let’s wrap our matEng expression in another set of curly braces...
In[]:=
{matEng}
Out[]//MatrixForm=
(
0.9
0.3
0.7
)
...this is also a nested list, which is a list within a list...
In[]:=
{{0.9,0.3,0.7}}
Out[]//MatrixForm=
(
0.9
0.3
0.7
)
...but it is still a List
In[]:=
Head[{matEng}]
Out[]=
List
Now we transpose our one row matrix and get a one column matrix where each element is its own row.
In[]:=
{matEng}
Out[]//MatrixForm=
0.9
0.3
0.7
Note how the number of levels and the content of those levels differ in the three presentations below
In[]:=
Head[matEng[[#]]]&/@Range[0,3](*intherowpresentationeachlevelbelowtheHeadisaReal*)
Out[]=
{Symbol,Real,Real,Real}
In[]:=
Head[{matEng}[[#]]]&/@Range[0,1](*thecolumnpresentationhasonlyonelevelaftertheHead,whichisaList*)
Out[]=
{Symbol,List}
In[]:=
Head[{matEng}[[#]]]&/@Range[0,3](*inthetransposedpresentationeachlevelbelowtheHeadisaList,albeitasingleelementListinthiscase*)
Out[]=
{Symbol,List,List,List}

The language of computer programmers and probabilists

In probability and computer programming the convention is different. These disciplines use the “matrix on the right” method which requires the Transpose of the original matrix. Note the super-scripted
T
transitionMatrix
in the code below. The answers are the same.
In[]:=
transitionMatrix
Out[]//MatrixForm=
0.8
0.1
0.1
0.2
0.7
0.1
0.1
0.3
0.6
In[]:=
matProb={1,0,1}.transitionMatrix
Out[]=
{0.9,0.3,0.7}
In[]:=
TrueQ[matEng==matProb]
Out[]=
True

A summary of how matrices are typically used in different fields

Mathematicians and Engineers:

• Matrix on the Left:
​​
• In this convention, the transition matrix is multiplied on the left of the state vector. This typically assumes the state vector is a column vector.
​​
• The transition matrix's columns represent the probabilities of transitioning from one state to another, while the state vector gives the current probabilities of being in each state.
​​
• The multiplication results in a new column vector, which represents the probabilities of being in each state after the transition.
​​
• In terms of a Markov process, this is a standard approach where the transition matrix operates on the state vector.

Computer Programmers and Probabilists

• Matrix on the Right:
​
​
• In this convention, the state vector is multiplied to the right of the transition matrix. Here, the state vector is treated as a row vector.
​
​
• The rows of the transition matrix represent the probabilities of transitioning from one state to another when multiplied this way.
​
​
• The multiplication results in a new row vector, which represents the probabilities after the transition.
​
​
• This approach can be more intuitive in programming and probabilistic contexts where operations often use row vectors.

Impact of Columns Becoming Rows

When transitioning from one convention to another, the role of rows and columns in the matrix changes: ​
• Mathematicians/Engineers: The columns of the transition matrix are the key elements, as they define what happens to the probabilities of being in each state.
​​
• Programmers/Probabilists: The rows become the key elements after transposition, as they define how the current state probabilities will change.
​The key is that converting between these two conventions often involves transposing the matrix to switch its rows and columns. This aligns the operations such that the outcome remains consistent despite the difference in vector orientation.​Understanding these conventions is crucial when working across disciplines, as it ensures that calculations are performed correctly regardless of the preferred matrix operation style. In practice, the choice between these conventions often depends on the context in which you’re working and the standard practices of the field.

Physics as arbitrator

Mathematica is influenced by Physics (Stephen Wolfram is, after all, a physicist by training). As such, Mathematica strives to be as general as possible. Careful thought will reveal that columns, rows and matrices are fine for one and two dimensions, but are special cases of a broader concept. When that breadth is considered, the entire edifice of columns and rows becomes irrelevant. A tensor in Mathematica is a nested list where each level of nesting corresponds to an additional dimension. Here is a simple 3D tensor (AKA a rank-3 tensor). Notice that, despite the $Post instruction, matrix formatting is ignored for this expression. This is natural since the $Post applies only to cases where the dimension is no more than 2.
One way to think of tensors is as nested “slices” within a larger system. Below is the first slice, a 2 x 2 matrix, which appears as MatrixForm because of our $Post instruction above
Mathematica provides Array to handle these conditions
And, as you see above and below, MatrixForm may be “forced” on a tensor to reflect the idea of a nested matrix...
...but because of the Head being different, you once again encounter the problem of using an expression wrapped in MatrixForm in calculations
Mentally visualizing higher-dimensional tensors (not easy!), one can think of a tensor as a stack of matrices (slices), where each element is uniquely identified by its position across dimensions.
​
It can be useful to show the slices of our 3-dimensional tensor in symbolic form to better understand the idea of its dimensions. Note below the first slice has the same initial subscript, 1...
...and the second slice the same initial subscript for all four is 2. Note in both cases, the remaining subscripts are the usual designation of columns and rows within the slice.
Wolfram has recently released, in Experimental form, several new symbols, VectorSymbol, ArraySymbol, ArrayDot and SymbolicIdentityArray. One hopes these enhancements bridge the gap between the disciplines.

CITE THIS NOTEBOOK

Matrices tutorial: lists, columns, and rows in Wolfram​
by Roger J Brown​
Wolfram Community, STAFF PICKS, March 24, 2025
​https://community.wolfram.com/groups/-/m/t/3431135