hilb

Hilbert matrix

Syntax

H = hilb(n)
H = hilb(n,classname)

Description

example

H = hilb(n) returns the Hilbert matrix of order n. The Hilbert matrix is a notable example of a poorly conditioned matrix. The elements of Hilbert matrices are given by H(i,j) = 1/(i + j – 1).

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

Examples

collapse all

Compute the fourth-order Hilbert matrix and its condition number to see that it is poorly conditioned.

H = hilb(4)
H = 4×4

    1.0000    0.5000    0.3333    0.2500
    0.5000    0.3333    0.2500    0.2000
    0.3333    0.2500    0.2000    0.1667
    0.2500    0.2000    0.1667    0.1429

cond(H)
ans = 1.5514e+04

Input Arguments

collapse all

Matrix order, specified as a scalar, nonnegative integer.

Example: hilb(10)

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

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

Example: hilb(10,'single')

Data Types: char

References

[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