This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Inverse of Hilbert matrix


H = invhilb(n)
H = invhilb(n,classname)



H = invhilb(n) generates the exact inverse of the exact Hilbert matrix for n less than about 15. For larger n, the invhilb function generates an approximation to the inverse Hilbert matrix.

H = invhilb(n,classname) returns a matrix of class classname, which can be either 'single' or 'double'.


collapse all

Compute the fourth-order inverse Hilbert matrix.

ans = 4×4

          16        -120         240        -140
        -120        1200       -2700        1680
         240       -2700        6480       -4200
        -140        1680       -4200        2800

Input Arguments

collapse all

Matrix order, specified as a scalar, nonnegative integer.

Example: invhilb(10)

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Matrix class, specified as either 'double' or 'single'.

Example: invhilb(10,'single')

Data Types: char


The exact inverse of the exact Hilbert matrix is a matrix whose elements are large integers. As long as the order of the matrix n is less than 15, these integers can be represented as floating-point numbers without roundoff error.

Comparing invhilb(n) with inv(hilb(n)) involves the effects of two or three sets of roundoff errors:

  • Errors caused by representing hilb(n)

  • Errors in the matrix inversion process

  • Errors, if any, in representing invhilb(n)

The first of these roundoff errors involves representing fractions like 1/3 and 1/5 in floating-point representation and is the most significant.


[1] Forsythe, G. E. and C. B. Moler. Computer Solution of Linear Algebraic Systems. Englewood Cliffs, NJ: Prentice-Hall, 1967.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

Introduced before R2006a