Documentation
Mathematica
Built-in Functions
Advanced Documentation
Linear Algebra
Introduction

Matrices as Mathematica Expressions
One important feature of matrices in Mathematica is that they are Mathematica expressions. This means that all of the Mathematica commands that operate on Mathematica expressions work on matrices. The same principle applies to vectors and tensors. The fact that all objects in Mathematica have a common expression structure greatly enhances the expressive nature of Mathematica programming. This principle, sometimes called the fundamental principle of Mathematica, may seem abstract, uninteresting, or obvious to people who have a background in purely numerical programming, but users who have a background in object oriented programming will recognize the benefits of a common parent object. Some examples of this principle will be discussed in this section.
As demonstrated above, a matrix can be entered with a list notation.
In[1]:=
One important way to understand Mathematica expressions is through the function FullForm. This shows the literal details of how the expression is arranged in Mathematica. In this case, the tree structure of the matrix is seen. There is an outer node, which is a List; in Mathematica this is called having a head of List. The outer node has two arguments, each of which has the head List; each of these has three arguments that are integers.
In[2]:=
Out[2]//FullForm=
The head of the matrix expression can be inspected with the function Head.
In[3]:=
Out[3]=
Length returns the number of arguments of the matrix expression.
In[4]:=
Out[4]=
Part can be used to extract elements of an expression.
In[5]:=
Out[5]=
Mathematica operations such as FullForm, Head, Length, and Part will work for any Mathematica expression. This is very convenient because it means that a common set of programming constructs will work for programming in many different applications, and not only for linear algebra. The same techniques apply to many other areas in Mathematica, for example, graphics programming, document programming, and symbolic algebra programming. These operations are often called structural operations because they work on the structure of Mathematica expressions. They can be contrasted with other operations that are specific to linear algebra. For example, the function MatrixQ is specific to matrix computation.
Expression Input and Output
Mathematica contains commands for I/O on expressions. It also has many commands for I/O with specially formatted data. The commands that can work with formatted data are reviewed in the section Import and Export of Matrices. In this section the Mathematica commands for I/O on expressions are reviewed.
The concept of the Mathematica FullForm is completely equivalent to that of serializable objects in Java or C#. The FullForm of any Mathematica expression is a complete specification of the expression. Saving the FullForm into a file and reading it back again will recreate the expression.
You can save a Mathematica expression into a file with the command Put, entered using >> as a short-cut notation.
In[1]:=
The contents of the file can be inspected with !!.
In[3]:=

The file can be read back into Mathematica with Get, entered using << as a short-cut notation.
In[4]:=
Out[4]=
This restores the matrix from the file so that it can be used for further computation.
Another way to do I/O on matrices in Mathematica is to use MathLink. This is an interprocess communication mechanism that is particularly useful for communicating between different Mathematica sessions.
Using Put and Get to store matrices in files is most useful if you want to save work from Mathematica to be restored later. If you want to exchange matrices with other applications, data saved in general formats is more useful; this is described in the section Import and Export of Matrices.