Documentation MathematicaBuilt-in Functions Advanced DocumentationLinear AlgebraMatrix Types
Matrices in Mathematica
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.
This matrix contains complex numbers with real and imaginary parts that are machine-precision approximate real numbers.
This matrix contains approximate numbers with 20 digits of precision.
This matrix contains integers.
This matrix contains rational numbers.
This matrix contains complex numbers with real and imaginary parts that are integers.
This matrix contains polynomials.
These different types of matrices can be put into categories according to the types of technique used for computing with them.
Different types of matrices in Mathematica.
These three different categories will be briefly reviewed.
Standard Numerical Techniques
In Mathematica, matrix computations involving machine-precision Real and machine-precision approximate Complex numbers are carried out with standard numerical techniques. In many cases computations involve optimized libraries, many of which are described in the Appendix: Software References.
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.
Arbitrary-Precision Numerical Techniques
In Mathematica, matrix computations involving arbitrary-precision Real and arbitrary-precision approximate Complex numbers are carried out with special numerical libraries. These libraries are adapted from standard libraries so they can work for arbitrary-precision computations.
More information can be found in the section Arbitrary-Precision Matrices.
Symbolic Algebra Techniques
Matrix computations involving exact numbers and general symbolic techniques are carried out with computer algebra techniques.
All computations provided for numerical matrices are also available for symbolic matrices. This meets the design goal of integrating symbolic and numerical computation.
Mixed Mode Matrices
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.
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 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.
The resulting matrix has entries with 20 digits of precision.
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.
The result is a machine-precision matrix.
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 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.