invhilb

Exact inverse of the Hilbert matrix.

Category: Mathematics > Elementary Math

Syntax

H = invhilb(n)

Returns the inverse of hilb(n), computed from a closed formula.

Description

The inverse of the Hilbert matrix has integer entries given by binomial-coefficient formulas, so it can be written down exactly without inverting anything. Calling inv(hilb(n)) for the same n goes through floating point and becomes inaccurate quickly, because hilb is badly conditioned; invhilb stays exact as long as the integers fit in a double.

It is handy as a reference solution when testing linear solvers.

Input arguments

n
Positive integer, the order of the matrix.

Output arguments

H
Symmetric matrix of integers with alternating-sign structure.

Example

Exact inverse

H = invhilb(3)
hilb(3) * H
Output
H = 3×3

     9   -36    30
   -36   192  -180
    30  -180   180
ans = 3×3

     1     0     0
     0     1     0
     0     0     1

See also

hilb inv cond gallery