I briefly covered Gaussian Elimination in Mathematica for small matrices. You can easily google gaussian elimination or consult an introductory Linear Algebra textbook if you like to know more. Going a whole lot higher in this discussion, we will try to see how we can shoe-horn Mathematica to “ill-conditioned” matrices such as the Hilbert Matrix. Hilbert matrices have cells with formulae H(i,j) = 1/(i+j-1). The determinant of the matrix can be had by knowing if a function f(n) can be defined such that , then the determinant of a Hilbert Matrix has the formula: . It may not look like it, but the numerator increases much faster than the denominator, causing the fraction to approach zero when *n* is large.

A sort of matrix can be made in Mathematica:

In[12]:= HilbertMatrix[15]
Out[12]= {{1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15},
{1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16},
{1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17},
{1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18},
{1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19},
{1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20},
{1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21},
{1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21, 1/22},
{1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21, 1/22, 1/23},
{1/10, 1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21, 1/22, 1/23, 1/24},
{1/11, 1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21, 1/22, 1/23, 1/24, 1/25},
{1/12, 1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21, 1/22, 1/23, 1/24, 1/25, 1/26},
{1/13, 1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21, 1/22, 1/23, 1/24, 1/25, 1/26, 1/27},
{1/14, 1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21, 1/22, 1/23, 1/24, 1/25, 1/26, 1/27, 1/28},
{1/15, 1/16, 1/17, 1/18, 1/19, 1/20, 1/21, 1/22, 1/23, 1/24, 1/25, 1/26, 1/27, 1/28, 1/29}}

This square matrix is classified as a Hilbert matrix, famous for being non-trivial to solve, even by computer. I fixed the output using the Rationalize[] function to show that what the Table[] function actually generated was a matrix of rational numbers. In addition, the output looks less like a matrix and more like a two-dimensional array. This tells you the implementation of matrices in Mathematica: it sees your matrix as “a kind of table”, or more accurately, “a kind of array”. The same array could have been generated repurposing the Table[] command:

** m = Rationalize[N[Table[1/(i + j - 1), {i, 15}, {j, 15}]]]**

This kind of formula also reminds us that the cells in the Hilbert Matrix are each made up of the values , giving it the familiar pattern of fractions we see.

Mathematica can present this as an actual matrix if pressed, using the MatrixForm[] command. Mathematica 10 even provides a direct HilbertMatrix[] command:

This command was invoked to produce the same Hilbert Matrix that we started earlier in this example. Mathematica 10 appears to choke on finding the determinant of this matrix (Det[] command), but what it does is echoes back your Det[] command with the expanded matrix. When that output is re-run, Mathematica returns with the determinant for this 15-by-15 matrix:

1/9446949653634668571373109351236989087975627994978804269595338137635022705891424600259116300098090513203200000000000000000000,

the denominator being a 123-digit number. As stated earlier, the determinant quickly goes to zero, but a square dimension of 15 is hardly a large matrix, suggesting that you need not go far to see this being demonstrated. Even the 5×5 version of the Hilbert Matrix has a determinant in the hundreds of billionths. Making it 3×3, the determinant is still 1/2160.