Matrices in *Mathematica* can contain many different types of elements.

For example, here is a matrix where each element is a machine-precision approximate real number.

In[1]:=

Out[1]//MatrixForm=

This matrix contains complex numbers with real and imaginary parts that are machine-precision approximate real numbers.

In[2]:=

Out[2]//MatrixForm=

This matrix contains approximate numbers with 20 digits of precision.

In[3]:=

Out[3]//MatrixForm=

This matrix contains integers.

In[4]:=

Out[4]//MatrixForm=

This matrix contains rational numbers.

In[5]:=

Out[5]//MatrixForm=

This matrix contains complex numbers with real and imaginary parts that are integers.

In[6]:=

Out[6]//MatrixForm=

This matrix contains polynomials.

In[7]:=

Out[7]//MatrixForm=

These different types of matrices can be put into categories according to the types of technique used for computing with them.

An important goal for many of these computations is to match and surpass the performance of any software package that is dedicated to machine-precision numbers. This is in keeping with the design goals of *Mathematica*, as described in the section Design Principles of Mathematica. In the case of linear algebra computations, *Mathematica* makes use of a considerable amount of sophisticated technology, some of which is described in the section Performance.

This section describes what happens if the input matrix contains a mixture of different types of entries.

If the matrix contains anything that is not a number (or something that cannot be converted into a number), the matrix will be treated as a symbolic matrix and the computation will proceed with symbolic techniques. In the following example, the presence of the x makes the matrix symbolic and the result is a symbolic matrix.

In[1]:=

Out[2]=

If the matrix only contains numbers (or things that can be converted into numbers), the computation will be done according to the lowest precision. Thus in the following example, the presence of the machine-precision approximate number, 1., means that the input matrix will be converted to machine-precision numbers and the computation done with machine-precision techniques.

In[3]:=

Out[4]=

In this example, the lowest precision is a number with 20 digits of precision. Thus, the input matrix will be converted to precision 20 numbers and the computation done with arbitrary-precision techniques.

In[5]:=

Out[6]=

The resulting matrix has entries with 20 digits of precision.

In[7]:=

Out[7]=

Note that machine-precision counts as lower precision than any arbitrary-precision numbers. In this example, because there is a machine-precision number, the input matrix will be converted to machine-precision numbers and the computation done with machine-precision techniques.

In[8]:=

Out[9]=

The result is a machine-precision matrix.

In[10]:=

Out[10]=

It is important to be aware of these distinctions. For example, if the input matrix consists of integers, the computation will use symbolic algebra techniques and return an exact precision result.

In[11]:=

Out[12]=

In some other computation systems an input matrix of integers would be converted to a floating point matrix. *Mathematica* does not do this, so that it can support symbolic computation. However, it means that users need to be aware of the differences. This is because the time required for a symbolic technique can be quite different from a machine-precision technique; in many cases the symbolic computation will take much longer.